Forum Moderators: coopster

Message Too Old, No Replies

identifying a value range for a $_POST variable

         

laura2k

12:38 pm on Feb 13, 2004 (gmt 0)



hello,

i have a form that submits to a php file, the form basically has a hidden field called number:

<input type="hidden" name="number" value="12">

i know how to read the value of that, its simply putting <?php echo $_POST['number']?> but what i want to do is check if the number is between 1 and 25 and if it is then echo A else if it is between 25-75 then echo B else if it is anything above 75 then echo C

can anyone please help me on this.

many thanx in advance

coopster

12:53 pm on Feb 13, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You could use a switch [php.net]:

$number = (isset($_POST['number']))? $_POST['number'] : 0;
switch ($number) {
case ($number <= 25):
echo 'A';
break;
case ($number <= 50):
echo 'B';
break;
default:
echo 'C';
break;
}