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?
Sill not working, I get a parse error no matter what I try and do. I had it kind of working before, but it would put Not Rated for all of them instead of just the empty ones, also I think my database sets all the ratings fields to "Null" as a default value. I tried plugging that in in place of "" but nothing happened. Any more ideas?
$Mrating = $line["MRating"];
$Wrating = $line["WRating"];
if (!$Mrating)
{$Mrating = "Not Rated";}
if (!$Wrating)
{$Wrating = "Not Rated";}
If that doesn't work, what exactly is the error you're getting? Have you tested the output of $Mrating before and after you re-assign it? Have you checked your query to make sure you're getting the right values in the first place?