Jump to content

If an event during a month exists, add month to list


Eiolon

Recommended Posts

So I am creating a list of events.  There will be a drop down menu to change between months.  I only want the months to be listed if an event during that month exists.

 

So if I have events listed for September and November, list only September and November, skipping October.  Any idea on how to approach this or if there are any functions for such a thing?

Link to comment
Share on other sites

Assuming your data is in a database table, the following query will return the month names present for a range of dates you are looking for (this assumes that the range of dates is less then one year) -

SELECT MONTHNAME(your_date_column) as mn FROM your_table WHERE your_date_column BETWEEN 'some_start_date' AND 'some_end_date' ORDER BY your_date_column

 

The month name would be available in the data you retrieve, something like $row['mn']

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.