I have an events list created with php/mysql which displays up and coming events in the next 14 days. The db has 8 fields
event_ID,
date_1,
date_2,
eventTitle,
eventDetails,
location,
publish,
updated.
I have created a list using this sql statement
SELECT gpe.*, gpr.name
FROM growl_presevents gpe, growl_presrail gpr
WHERE gpe.location LIKE gpr.railID AND (date_1 >= '$today' AND date_1 <= '$week')
AND gpe.publish = 'y'
ORDER BY date_1 ASC
The arrays are filled by these statements
$today = date('Y-m-d'); /// Todays date
$week = date('Y-m-d', time() + (86400*14)); /// Todays date + 14 days
The list is fine, but I need a tweak so that an event is displayed if it lasts for more than one day, and the date_1 is outside the 14 day period.
e.g. (just example data not actual)
if today is 2012-02-01
date_1 date_2 location Title details
2012-02-07 NULL Loc001 Show Stage show
2012-02-13 2012-02-18 Loc002 Open Air Festival
2012-02-17 NULL Loc001 Comedy Comedy Show
Using my SQL query above, the first two dates would show ‘$today’, on the ‘3rd’ all three would be displayed, then on the ‘8th’ the first row would disappear. All OK so far, but this is where I need help. Using this query on the ’14th’ row 2 would disappear, but the event is on until the 18th, therefore I want it to still display until the 18th.
There is probably an easy way of doing this, but I have not been able to fathom it out, so any help would be much appreciated.
Thanks
Phil
Try this
So basically do the same check on date_2 as you do on date_1 as an OR. Use ISNULL to provide 0 if a NULL date is found.