Using an if statement to check for blank database entries
Posted: Fri Sep 26, 2003 5:44 pm
Hello,
I have got my page working for the most part now, but I'm trying to add an if statement.
What I want it to do is check to see if there is anything in the field, if there isn't I want it to print "Not Rated". This is the code I have so far.
MRating and WRating are the names of a field in a database, they should have a rating out of 10. eg. 2/10 4/10 etc. but if they are empty, I want the words "Not Rated" to be put in their place. Can anyone tell me what is wrong with this code?
Thanks again,
Will Mowat
wmowat@nearnorthweb.com
I have got my page working for the most part now, but I'm trying to add an if statement.
What I want it to do is check to see if there is anything in the field, if there isn't I want it to print "Not Rated". This is the code I have so far.
MRating and WRating are the names of a field in a database, they should have a rating out of 10. eg. 2/10 4/10 etc. but if they are empty, I want the words "Not Rated" to be put in their place. Can anyone tell me what is wrong with this code?
Code: Select all
$Mrating = $lineї'MRating'];
$Wrating = $lineї'WRating'];
if (empty($Mrating))
{then $Mrating = "Not Rated";}
if (empty($Wrating))
{then $Wrating = "Not Rated";}Will Mowat
wmowat@nearnorthweb.com