Jump to content

Need Help With Else If Script


ryanfilard

Recommended Posts

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

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.