Jump to content

pho more than and less than


besly98

Recommended Posts

If its a number then no it wont need to be in "", however php will convert between a sting and number for you anyway so it doesn't matter to much.

 

The only other thing I can think it could be is it's getting caught by an if statement further up. Have you got the whole chunk of code?

this is the full code

 

if ($tactic =="442" &&  $rating <= 200) {

  echo rand(0, 1);  }

  elseif ($tactic == "442" && $rating >= 200 && $rating <= 441) {

  echo rand(0, 2);

  }

  elseif ($tactic == "442" && $rating >= 441 && $rating <= 550) {

  echo rand(0, 3); 

  }

  elseif ($tactic == "442" && $rating >= 551 && $rating <= 660) {

  echo rand(0, 4);   

  }

  elseif ($tactic == "442" && $rating >= 661 && $rating <= 770) {

  echo rand(0, 4);   

  }

  elseif ($tactic == "442" && $rating >= 771 && $rating <= 880) {

  echo rand(1, 5);   

  }

  elseif ($tactic == "442" && $rating >= 881 && $rating <= 990) {

  echo rand(1, 6); 

  }

    elseif ($tactic == "442" && $rating >= 991) {

  echo rand(1, 7); 

  }

 

the number is 1000 so it shoudl get to the last if... but it doesnt print anything. and the tactic is 442

IF I use this test data on that block of code it works fine. so it's not even getting to those set of statements by the looks of things.


<?php
$rating = 1000;
$tactic = "442";

if ($tactic =="442" &&  $rating <= 200) {
	echo rand(0, 1);  
   } 
   elseif ($tactic == "442" && $rating >= 200 && $rating <= 441) {
echo rand(0, 2);
   }
   elseif ($tactic == "442" && $rating >= 441 && $rating <= 550) {
echo rand(0, 3);  
   }
   elseif ($tactic == "442" && $rating >= 551 && $rating <= 660) {
echo rand(0, 4);    
   }
   elseif ($tactic == "442" && $rating >= 661 && $rating <= 770) {
echo rand(0, 4);    
   }
   elseif ($tactic == "442" && $rating >= 771 && $rating <= 880) {
echo rand(1, 5);    
   }
   elseif ($tactic == "442" && $rating >= 881 && $rating <= 990) {
echo rand(1, 6);  
   }
   if ($tactic == "442" && $rating >= 991) {
   echo rand(1, 7);  
   }

?>

 

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.