stublackett Posted June 27, 2008 Share Posted June 27, 2008 Hi, I've got a MySQL Select Script setup It selects the data no problems, What I'd like to do is if the SQL Data that is empty or doesnt match the SQL Command, How do I say "No News In The Archive" ?? My code is <?php $result = mysql_query("SELECT * , DATE_FORMAT( date, '%c' ) AS month FROM news WHERE date >= 1 & date <=3"); //&c is the month number (i.e 1 for January, 2 for Feb etc) while($myrow = mysql_fetch_assoc($result)) {//begin of loop $date = $myrow['month']; $title = $myrow['title']; $description = $myrow['description']; if ( $date >= 1 && $date <= 3) { //Winter News Archive echo "<h2>$title</h2>"; echo "<div id='description'>$description</div>"; echo "<br>"; } }//End While loop ?> Link to comment https://forums.phpfreaks.com/topic/112169-if-an-mysql-row-is-empty-how-do-i-echo-that-it-is/ Share on other sites More sharing options...
waynew Posted June 27, 2008 Share Posted June 27, 2008 Here you go: if(mysql_num_rows($result) == 0) //its empty Hope that helped. Link to comment https://forums.phpfreaks.com/topic/112169-if-an-mysql-row-is-empty-how-do-i-echo-that-it-is/#findComment-575825 Share on other sites More sharing options...
stublackett Posted June 27, 2008 Author Share Posted June 27, 2008 Haha, Should have worked that out myself Especially with the == already being in my code Thanks for that though Link to comment https://forums.phpfreaks.com/topic/112169-if-an-mysql-row-is-empty-how-do-i-echo-that-it-is/#findComment-575827 Share on other sites More sharing options...
waynew Posted June 27, 2008 Share Posted June 27, 2008 No problem. Link to comment https://forums.phpfreaks.com/topic/112169-if-an-mysql-row-is-empty-how-do-i-echo-that-it-is/#findComment-575830 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.