Eiolon Posted August 6, 2010 Share Posted August 6, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/209990-if-an-event-during-a-month-exists-add-month-to-list/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 6, 2010 Share Posted August 6, 2010 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'] Quote Link to comment https://forums.phpfreaks.com/topic/209990-if-an-event-during-a-month-exists-add-month-to-list/#findComment-1096047 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.