nepzap2 Posted January 14, 2009 Share Posted January 14, 2009 First I want to thank all of you for all your help. I need a little help with this query, I'm trying to check if the column "active" in the sa_events table has any rows with the word yes to print otherwize print all the other rows that have the word no. My query prints the row with the word yes in the active column but when I delete it it does not print it doesn't print the row with the word no. Any help is greatly appreciated. Below is my code. Thanks <?php include 'zdb_config.php'; $data = mysql_query("SELECT * FROM sa_events WHERE sa_events.active = 'yes'") or die(mysql_error()); while($info = mysql_fetch_array($data)) if ($data) { print "<p style='line-height: 12px;'>" .$info['id']. "<br />" .$info['title']. "<br />" .$info['date_time']. "<br />" .$info['category']. "<br />" .$info['speaker']. "<br />" .$info['room']. "<br />" .$info['description']. "</p>"; } else { $data = mysql_query("SELECT * FROM sa_events WHERE sa_events.active = 'no'") or die(mysql_error()); while($info = mysql_fetch_array($data)) print "<p style='line-height: 12px;'>" .$info['id']. "<br />" .$info['title']. "<br />" .$info['date_time']. "<br />" .$info['category']. "<br />" .$info['speaker']. "<br />" .$info['room']. "<br />" .$info['description']. "</p>"; } ?> Quote Link to comment Share on other sites More sharing options...
trq Posted January 14, 2009 Share Posted January 14, 2009 mysql_query returns true if your query is successful. A successful query does not however mean it found any rows, its just means it executed without error. You'll want to check mysql_num_rows. Quote Link to comment 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.