bradkenyon Posted April 10, 2008 Share Posted April 10, 2008 i am trying to only display the events that are not expired. i was thinking that i could do an if statement within the loop, testing if the date is less than the current date, then do not display. any help would be appreciated. while($row = mysql_fetch_array($result)) { $i = 0; $t = 1; while($i <=0) { if($row['expiredate'] > date("Y-m-d",time())) { print '<li><strong>'.date("m/d/y",strtotime($row['expiredate'])).'</strong> - '; if($row['moreurl'] != '') { print '<a href="'.$row['moreurl'].'" target="blank">'.$row['subj'].'</a> - '.$row['location'].''; } else { print $row['subj'].' - '.$row['location']; } print '</li>'; $i++; $t++; } } } Quote Link to comment https://forums.phpfreaks.com/topic/100513-do-not-display-expired-events/ Share on other sites More sharing options...
rhodesa Posted April 10, 2008 Share Posted April 10, 2008 Wouldn't it be better to filter them out on the SQL level? What is your SQL query? Should looks something like: SELECT * FROM events WHERE expiredate > NOW() Quote Link to comment https://forums.phpfreaks.com/topic/100513-do-not-display-expired-events/#findComment-514055 Share on other sites More sharing options...
bradkenyon Posted April 10, 2008 Author Share Posted April 10, 2008 PERFECT! Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/100513-do-not-display-expired-events/#findComment-514070 Share on other sites More sharing options...
cooldude832 Posted April 10, 2008 Share Posted April 10, 2008 if the experidate holds the time they expire then it should be less than the current time "NOW()" that query as given will expire all events that expire after "NOW()" instead of all expiring before "NOW()" Quote Link to comment https://forums.phpfreaks.com/topic/100513-do-not-display-expired-events/#findComment-514074 Share on other sites More sharing options...
bradkenyon Posted April 10, 2008 Author Share Posted April 10, 2008 I'm looking for the event to stay until 11:59pm of that date, so people can see what happened that day, even if the event was over for a couple hours. Quote Link to comment https://forums.phpfreaks.com/topic/100513-do-not-display-expired-events/#findComment-514077 Share on other sites More sharing options...
cooldude832 Posted April 10, 2008 Share Posted April 10, 2008 I'm looking for the event to stay until 11:59pm of that date, so people can see what happened that day, even if the event was over for a couple hours. then your field expiredate should be adjusted to equal 11:59:59 of the day you want to expire so that NOW() won't trap em. Or you can avoid NOW() and use php's mktime function to make it 11:59:59 of today Quote Link to comment https://forums.phpfreaks.com/topic/100513-do-not-display-expired-events/#findComment-514085 Share on other sites More sharing options...
bradkenyon Posted April 10, 2008 Author Share Posted April 10, 2008 anyway i can modify NOW() to add a day to NOW() so it will include a 4/10 on the day it is 4/10? Quote Link to comment https://forums.phpfreaks.com/topic/100513-do-not-display-expired-events/#findComment-514090 Share on other sites More sharing options...
cooldude832 Posted April 10, 2008 Share Posted April 10, 2008 anyway i can modify NOW() to add a day to NOW() so it will include a 4/10 on the day it is 4/10? say what? Subject verb object can't translate? Quote Link to comment https://forums.phpfreaks.com/topic/100513-do-not-display-expired-events/#findComment-514099 Share on other sites More sharing options...
bradkenyon Posted April 10, 2008 Author Share Posted April 10, 2008 As you mentioned before, w/ the query SELECT * FROM events WHERE expiredate > NOW() is there anyway you can modify the query so it displays the event that has the same date, for example.... Red Cross Blood Drive 4/10/2008 Today's date is 4/10/2008. I want to display that event until the day is over, I was thinking you could modify the query like this... SELECT * FROM events WHERE expiredate > NOW() + 1 or SELECT * FROM events WHERE expiredate >= NOW() Quote Link to comment https://forums.phpfreaks.com/topic/100513-do-not-display-expired-events/#findComment-514105 Share on other sites More sharing options...
bradkenyon Posted April 10, 2008 Author Share Posted April 10, 2008 got it, set it to be 23:59:59. Quote Link to comment https://forums.phpfreaks.com/topic/100513-do-not-display-expired-events/#findComment-514118 Share on other sites More sharing options...
rhodesa Posted April 10, 2008 Share Posted April 10, 2008 Do what works for you, but in my opinion, if you want the Blood Drive to be displayed all day on the 4/10/2008, it would expire technically on 4/11/2008. Quote Link to comment https://forums.phpfreaks.com/topic/100513-do-not-display-expired-events/#findComment-514120 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.