I've been told this isn't possible which leads me to the following problem.

I have a series of events stored in a database and at the moment I pull the info out and display each one on a new line using a while loop.

What I'd like to do now is check that if the date is 0000-00-00 then the date must not be displayed.

Here's what my code looks like at the moment (without checking if the date is 0000-00-00):

<?php	
// open connection to MySQL server
$connection = mysql_connect('localhost', 'username', 'password')
or die ('Unable to connect!');
							
//select database
mysql_select_db('database') or die ('Unable to select database!');
						
//create and execute query
$query = "SELECT heading, day(date), monthname(date), year(date), description FROM event ORDER BY date";
$result = mysql_query($query) or die ('Error in query: $query. ' . mysql_error());
									
if (mysql_num_rows($result) > 0 )
{
    while($row = mysql_fetch_row($result)) 
    {							
    echo "<tr>";
    echo "<td><p>".$row[0]."</p><p>".$row[1]." ".$row[2]." ".$row[3]."</p><p>".$row[4]."</p></td>";
    echo "</tr>";
    }
}
?>

If you can help me then you might get a cookie...the edible kind ;)

of course you can put an if statement inside a while.If you want to check if the date is not
0000-00-00,you must include the date in your select statement like this:

$query = "SELECT heading, day(date), monthname(date), year(date),description,date FROM event ORDER BY date";

then proceed with your while statement with the if:

while($row = mysql_fetch_row($result)) 
    {		
	 if ($row[5]=="0000-00-00")
		{
                 // do nothing...
                 }	
         else
                {
                echo "<tr>";
               echo "<td><p>".$row[0]."</p><p>".$row[1]." ".$row[2]."           ".$row[3]."</p><p>".$row[4]."</p></td>";
    echo "</tr>";
               }
    }

Let me know if I had helped you,I want to get that cookie!:D

You are a life saver ryan ;) *hands ryan a cookie*

Just goes to show. Don't listen to wannabe coders.

It's ok dude.Happy PHP-ing!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.