tpsilver10 Posted May 15, 2007 Share Posted May 15, 2007 I've got this dropdown trying to call the data in...basically, I only want it to show if it is an upcoming event. Past events are hidden away in the archives. I can get it to work if I remove the if ($row['date'] etc, but not with it in. Can anyone spot any errors with my code? <?php $query = "SELECT description FROM events"; $result = mysql_query($query); echo "<select name=\"events\">"; while($row = mysql_fetch_assoc($result)){ if ($row['date'] >= date('Y-m-d')){ displayEvents($row); echo "<option name=\"description\" value=\"$row[description]\" class=\"formstyles\" />$row[description]</option>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/51516-solved-drop-down-displaying-mysql-data/ Share on other sites More sharing options...
clown[NOR] Posted May 15, 2007 Share Posted May 15, 2007 it might be that you don't have any values in the database that's higher or equal to today's date... Quote Link to comment https://forums.phpfreaks.com/topic/51516-solved-drop-down-displaying-mysql-data/#findComment-253705 Share on other sites More sharing options...
tpsilver10 Posted May 15, 2007 Author Share Posted May 15, 2007 Haha...I'm not that silly dude Quote Link to comment https://forums.phpfreaks.com/topic/51516-solved-drop-down-displaying-mysql-data/#findComment-253707 Share on other sites More sharing options...
clown[NOR] Posted May 15, 2007 Share Posted May 15, 2007 hehe... gotta rule out everything Quote Link to comment https://forums.phpfreaks.com/topic/51516-solved-drop-down-displaying-mysql-data/#findComment-253708 Share on other sites More sharing options...
clown[NOR] Posted May 15, 2007 Share Posted May 15, 2007 what is you add strtotime()?? if (strotime($row['date']) >= strtotime(date("Y-m-h))) Quote Link to comment https://forums.phpfreaks.com/topic/51516-solved-drop-down-displaying-mysql-data/#findComment-253711 Share on other sites More sharing options...
tpsilver10 Posted May 15, 2007 Author Share Posted May 15, 2007 Like this? <?php $query = "SELECT description FROM events"; $result = mysql_query($query); echo "<select name=\"events\">"; while($row = mysql_fetch_assoc($result)){ if (strotime($row['date']) >= strtotime(date("Y-m-h"))){ displayEvents($row); echo "<option name=\"description\" value=\"$row[description]\" class=\"formstyles\" />$row[description]</option>"; } } ?> Cos that one didn't work...hmmm... Quote Link to comment https://forums.phpfreaks.com/topic/51516-solved-drop-down-displaying-mysql-data/#findComment-253715 Share on other sites More sharing options...
clown[NOR] Posted May 15, 2007 Share Posted May 15, 2007 hmmm yeah that's what I ment... what If you try this $query = "SELECT * FROM events"; Quote Link to comment https://forums.phpfreaks.com/topic/51516-solved-drop-down-displaying-mysql-data/#findComment-253717 Share on other sites More sharing options...
tpsilver10 Posted May 15, 2007 Author Share Posted May 15, 2007 Nope no good on that one either. It's very strange... Quote Link to comment https://forums.phpfreaks.com/topic/51516-solved-drop-down-displaying-mysql-data/#findComment-253723 Share on other sites More sharing options...
tpsilver10 Posted May 15, 2007 Author Share Posted May 15, 2007 Got it! <?php $query = "SELECT * FROM events ORDER BY date, time"; $result = mysql_query($query); echo "<select name=\"events\">"; while($row = mysql_fetch_assoc($result)){ if ($row['date'] >= date('Y-m-d')){ displayEvents($row); echo "<option name=\"description\" value=\"$row[description]\" class=\"formstyles\" />$row[description]</option>"; } } ?> Thanks for trying champ. Quote Link to comment https://forums.phpfreaks.com/topic/51516-solved-drop-down-displaying-mysql-data/#findComment-253735 Share on other sites More sharing options...
clown[NOR] Posted May 15, 2007 Share Posted May 15, 2007 np... Quote Link to comment https://forums.phpfreaks.com/topic/51516-solved-drop-down-displaying-mysql-data/#findComment-253737 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.