Page 1 of 1
if-code
Posted: Wed Nov 23, 2005 11:34 am
by ben_albrechts
Hey all,
i need some help AGAIN.
I need a code that if $var1 = 1 the outcome = A
but if $var1 = any number from 2 to 10 , the outcome = B
and if $var = more then 10, the outcome = C
is this possible? It's mainly the second bit i have problems with , i dont know how to put 'a number from 2 to 10' in my 'if'-session.
Thanks for the help
Posted: Wed Nov 23, 2005 11:42 am
by Charles256
um if number is greater or equal to 2 and number is less than equal to ten.......
right?
or did i miss something?
Re: if-code
Posted: Wed Nov 23, 2005 11:45 am
by ambivalent
ben_albrechts wrote:
is this possible? It's mainly the second bit i have problems with , i dont know how to put 'a number from 2 to 10' in my 'if'-session.
Code: Select all
if (($var1 >= 2) && ($var1 <=10)) {
//kinda like that?
Re: if-code
Posted: Wed Nov 23, 2005 11:46 am
by trukfixer
ben_albrechts wrote:Hey all,
i need some help AGAIN.
I need a code that if $var1 = 1 the outcome = A
but if $var1 = any number from 2 to 10 , the outcome = B
and if $var = more then 10, the outcome = C
is this possible? It's mainly the second bit i have problems with , i dont know how to put 'a number from 2 to 10' in my 'if'-session.
Thanks for the help
http://us2.php.net/manual/en/language.c ... ctures.php <--- THE MANUAL
Code: Select all
if($var1 == 1)
{
$outcome = "A";
}
elseif($var1 >1 && $var1 < 11)
{
$outcome = "B";
}
else
{
$outcome = "C";
}
Posted: Wed Nov 23, 2005 11:50 am
by Charles256
learn PHP in 24 hours by Sams is pretty good. I recommend spending the 30-50 bucks on it. You'll pick up a lot of good information,very fast.
Posted: Wed Nov 23, 2005 11:01 pm
by harrisonad
I think Truckfixer gave the solution already.