Jump to content

If an MySQL Row is Empty How do I echo that it is??


stublackett

Recommended Posts

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
         						
?>

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.