natefanaro
Technical User
I am trying to find out what value has the largest number, then display the appropriate result from a database. $a, $b, and $c all have a number value. (1-5 so far) and whatever is the largest value, it will show the corresponding value ($a shows $num1, $b shows $num2, $c shows $num3). I am able to get it to show the right answer as long as there is not a tie (ie $a = 2 and $b = 2) by using the bottom script. Any ideas on how to A) get the thing working where if there is a tie (ie $a = 2 and $b = 2), it will just show the value for $a, and B) maybe shorten up this code a bit? Thanks in advance.
if ($a > $b ) {
if ($a > $c ) {
echo "$num1";
}
}
if ($b > $a) {
if ($b > $c) {
echo "$num2";
}
}
if ($c > $a) {
if ($c > $b) {
echo "$num3";
}
}
if ($a > $b ) {
if ($a > $c ) {
echo "$num1";
}
}
if ($b > $a) {
if ($b > $c) {
echo "$num2";
}
}
if ($c > $a) {
if ($c > $b) {
echo "$num3";
}
}