...

View Full Version : Best Way To Do This



Inersha
08-15-2008, 01:17 PM
I am trying to make a small script that gives an specific output given a certain combination of two input values. I am currently doing it with if, elseif and else statements which works fine up to a point, but I am wondering if there is a better and cleaner way to go about things.

Basically, I want PHP to give a certain output depending on the country of the visitor and a number that they enter.

For example, the script is a little like this...


if ($country == "country" && $money < 50) {

echo 'something';

}

elseif ($country == "country" && $money=> 50 && $money <= 50000) // this will not work - too many &&s i think. {

echo 'something else';

}

The script goes on for a few more elseif statements, but I guess the biggest problem if giving an output if a person is from a certain country and the money value is BETWEEN two numbers.

What would be the best solution?

abduraooft
08-15-2008, 01:47 PM
if($country == "country" ){
if($money < 50)
echo 'something';
elseif($money>= 50 && $money <= 50000)
echo 'something else';
}

masterofollies
08-15-2008, 02:18 PM
if($country == "country" ){
if($money < 50)
echo 'something';
elseif($money>= 50 && $money <= 50000)
echo 'something else';
}

On my website the elseif start and closing has to be like this.


elseif(($money>= 50) && $money <= 50000)
echo 'something else';

In case you have problems, try that way.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum