ryanfilard Posted October 12, 2011 Share Posted October 12, 2011 This does not work correctly and I need help with it. If $rating is equal to zero it displays 4 stars on this page http://rwdev.whekle.com/view.php?id=4571 what I am doing wrong, it is probably a simple mistake. if($rating <= '1.5'){ $star1 = "yes"; }elseif($rating <= '2.5'){ $star2 = "yes"; }elseif($rating <= '3.5'){ $star3 = "yes"; }elseif($rating <= '4.5'){ $star4 = "yes"; }elseif($rating <= '5.0'){ $star5 = "yes"; } Link to comment https://forums.phpfreaks.com/topic/248939-need-help-with-else-if-script/ Share on other sites More sharing options...
codefossa Posted October 12, 2011 Share Posted October 12, 2011 A much easier way would be simply: $stars = round($rating); Link to comment https://forums.phpfreaks.com/topic/248939-need-help-with-else-if-script/#findComment-1278447 Share on other sites More sharing options...
MasterACE14 Posted October 12, 2011 Share Posted October 12, 2011 if($rating <= 1.5 && $rating > 0){ // IF rating is Less Than or Equal to 1.5 AND greater than zero... $star1 = 'yes'; $star1 = "yes"; }elseif($rating <= 2.5 && $rating > 1.5){ $star2 = "yes"; }elseif($rating <= 3.5 && $rating > 2.5){ $star3 = "yes"; }elseif($rating <= 4.5 && $rating > 3.5){ $star4 = "yes"; }elseif($rating <= 5.0 && $rating > 4.5){ $star5 = "yes"; } that should do the trick. I think... Link to comment https://forums.phpfreaks.com/topic/248939-need-help-with-else-if-script/#findComment-1278449 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.