OK so let me understand this..
You are going to have a form with 3 input fields that are for inputting integers which will be assigned to $a, $b, and $c
Then based upon the input you need to be able to sort them?
There are much better ways to do this rather than if else such as
Code: Select all
$numbers = array($a,$b,$c); ## Store the integers in an array
$lowtohigh = sort($numbers); ## Sort the Array from low to high
$hightolow = arsort($numbers); ## Sort the Array from high to low
foreach ($lowtohigh as &$value) {
echo "$value<br>";
}
echo "<br><br>";
foreach ($hightolow as &$value) {
echo "$value<br>";
}
If you definitely have to use an if else just think through the logic to determine which is the largest number
if $a > $b and $a > $c you know $a will be the largest.
if $a > $b but $a < $c then you know $b will be the largest
if $a < $b then compare $b to $c to see which is the largest
Once you have the largest you can use else statements to display the other two values.
hope that helps.