View Single Post
Old 02-06-2005, 01:45 PM   #1 (permalink)
Wysocki
Recruit
 
Join Date: Jan 2005
Location: Covina, CA
Posts: 23
Wysocki is on a distinguished road
How to test for empty date from MySql call?

Code:
$result=mysql_query("SELECT * FROM sk_recvitem WHERE 1");
$shipdate=mysql_result($result,1,"shipdate");
if ($shipdate = "0000-00-00") $shipdate="NONE";
I have the above code accessing a MySql database to return a date field so I can place it on my webpage. If the date field has not been set, the value in $shipdate shows up as 0000-00-00 but I'd like the field to show NONE. The above IF test ALWAYS evaluates to true though. I can't use empty($shipdate) because it appears to contain 10 characters. How should I test for this?
Wysocki is offline   Reply With Quote