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?

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']

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.