Forum Moderators: coopster

Message Too Old, No Replies

show biggest value first

         

skoff

3:52 am on Mar 1, 2009 (gmt 0)

10+ Year Member



hi!
I tried a lot of possibility but i never success to do what i want!
So i'm here to ask you some help! :)

What i want to do i have two columns (field_3,field_4) in these two columns I have numbers. I want to show these numbers and i have to make a query but i dont know how to write it. What i want to do is this :
If the number of field_3 is bigger i want to show it before field_4. But if field_4 is bigger than field_3 i want to show it first. After that i need to be able to show only one line a the time(where id=1 etc) Here's an example :

ID¦field_3¦field_4¦
--¦-------¦-------¦
01¦---3---¦---4---¦
02¦---5---¦---1---¦

i want to display these number in a table on a web page but i need to show these numbers like this :

Win 4 to 3
Win 5 to 1

because it make no sense to display the score of a game like this :

Win 3 to 4
Win 1 to 5

Clearly i need to show the biggest value between the two columns first
I hope that i was clear?!? sorry for my bad english!

blang

6:27 am on Mar 1, 2009 (gmt 0)

10+ Year Member



Should be simple enough with a couple of ternary statements, e.g.

$var1= 3;
$var2= 4;

echo ( $var1 > $var2 ) ? $var1 : $var2;
echo ' : ';
echo ( $var1 < $var2 ) ? $var1 : $var2;

You could potentially work it out in your SELECT statement, but doing it in PHP is efficient and just a couple of lines of code.