Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 827921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:38:50+00:00 2026-05-15T03:38:50+00:00

I’ve built a pretty shnazzy calendar system but there is one tweak that I

  • 0

I’ve built a pretty shnazzy calendar system but there is one tweak that I need to make so that I’m completely happy with it.

My calendar has three tables:

calevents – The calendared event.

caldates – The occurrences and date-range of each occurrence for each event.

calcats – The categories that can be applied to an event.

The short:

For each calevent, there can be many caldates, one for each occurrence of calevent. So a calevent that repeats weekly and spans 3 days might have caldates like this:

date_id   date_eid   date_start   date_end
2         37         2010-06-21   2010-06-23
3         37         2010-06-28   2010-06-30
7         37         2010-07-05   2010-07-07
9         37         2010-07-12   2010-07-14

What I want to do, is when selecting all the caldates for a specified month such as 2010-06, to return not just the two records above, but instead a record for each date in the range of date_start and date_end for each caldate.

So if I searched for 2010-06, I would get:

date_id   date_eid   date_start   date_end     date_day
2         37         2010-06-21   2010-06-23   2010-06-21
2         37         2010-06-21   2010-06-23   2010-06-22
2         37         2010-06-21   2010-06-23   2010-06-23
3         37         2010-06-28   2010-06-30   2010-06-28
3         37         2010-06-28   2010-06-30   2010-06-29
3         37         2010-06-28   2010-06-30   2010-06-30

The Long:

The reason I want to do this, is so when displaying a list of events(calevents) for a specified month, an occurrence(caldates) of that event will be displayed for EACH of the days it spans.

I could do this with php by looping through each day of the current month and displaying a copy of each caldate if the month day falls between date_start and date_end. But doing it this way will prevent me from using record pagination if needed.

For example, if for a specified month the following caldates were returned:

date_id   date_eid   date_start   date_end
2         37         2010-06-21   2010-06-27
94        53         2010-06-09   2010-07-08

Doing record pagination would see this as only 2 records(“rows”). But looping through them with PHP would generate 29 “rows”.

So, I figure if I use mysql to create each row instead of PHP, I can achieve the same thing AND still be able to use pagination if a month has a lot of events/dates.

As far as performance goes, I’m not sure which option is more efficient. Both would send the same amount of info to the browser, so it’s really only the work required to generate the info that matters.

My current query which fetches all the occurrences for a specified month, and to make things just a little more complicated… joins them with their event and category, looks like this:

$sql_to_execute = "
SELECT
  date_id,
  date_eid,
  date_start,
  date_end,
  event_id,
  event_title,
  event_category,
  event_private,
  event_location,
  SUBSTRING_INDEX(event_detailsstripped, ' ', 40) AS event_detailsstripped,
  event_time,
  event_starttime,
  event_endtime,
  event_active,
  cat_colour
FROM
  (
  caldates
LEFT JOIN
  calevents
ON
  caldates.date_eid = calevents.event_id
  )
LEFT JOIN
  calcats
ON
  calevents.event_category = calcats.cat_id
WHERE
  date_start <= '".mysql_real_escape_string($dbi_list_end_date)."'
  AND date_end >= '".mysql_real_escape_string($dbi_list_start_date)."'
  ".$dbi_category."
ORDER BY
  date_start ASC
"; 

Any help or advice would be greatly appreciated!

Thanks,

Peter

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:38:51+00:00Added an answer on May 15, 2026 at 3:38 am

    The easiest thing to do what you want would be to:

    • Generate a table of ALL dates (within a reasonable range)

    • Join caldates table to all_dates table:

      SELECT * FROM caldates, all_dates
      WHERE all_dates.date BETWEEN "2010-06-01" AND "2010-06-30"
      AND   all_dates.date BETWEEN caldates.date_start AND caldates.date_end
      

      Add a join to calevents as you wish

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I need to clean up various Word 'smart' characters in user input, including but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.