I'm using the mysql GREATEST() function to select the highest integer value from either column (apples or peaches).
+----+------------------+
| id | apples | peaches |
+----+------------------+
| 1 | 8 | 4 |
| 2 | 2 | 6 |
| 3 | 3 | 9 |
| 4 | 7 | 2 |
| 5 | 4 | 4 |
+----+------------------+
Using $result = "SELECT GREATEST(apples, peaches) FROM table";
and echo $result
, I get:
8
6
9
7
Next to each value, I want to echo the corresponding fruit name and a fruit icon. How can I achieve the image below via the MYSQL query?
Also, notice that equal values aren't displayed by the GREATEST()
function. Is there a way to display the equal value as well?