bford21 Posted July 12, 2010 Share Posted July 12, 2010 I am in the process of creating a basic ratings system and I am running into some trouble. To me this code makes perfect sense but for some reason it isn't working. I think it has something to do with the way MySQL handles zeros or something because if I change $rating = 1 and change tut_rating to 1 in my database it works fine. Thanks in advance. $qry = "SELECT tut_rating FROM html_tuts WHERE tut_id=$tut_id"; $rating = mysql_query($qry); if($rating = 0.00){ echo "<img src='Images/3.5.gif' width='70' height='18'>"; } else{ echo "error"; } Quote Link to comment Share on other sites More sharing options...
marcus Posted July 12, 2010 Share Posted July 12, 2010 <?php $sql = "SELECT tut_rating FROM `html_tuts` WHERE `tut_id` = '".$tut_id."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) > 0){ $row = mysql_fetch_assoc($res); if($row['rating'] == '0.00'){ echo "that img"; }else { echo "error"; } }else { echo "invalid tutorial id"; } ?> Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted July 12, 2010 Share Posted July 12, 2010 I would think something like this: $qry = "SELECT `tut_rating` FROM `html_tuts` WHERE `tut_id`='$tut_id'"; $rating = mysql_query($qry); if($rating['tut_rating'] == '0.00'){ echo "<img src='Images/3.5.gif' width='70' height='18'>"; } else{ echo "error"; } Quote Link to comment Share on other sites More sharing options...
bford21 Posted July 12, 2010 Author Share Posted July 12, 2010 Thanks guys. I knew it would be something simple. My brain is just about fried right now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.