Good day. Such situation, is mysql. In it, the label znacheniya is admissible, and in this label such columns are: id, name, chislo. In the same table these values:

1 - id, name - Tolya, chislo - 1; 2 - id, name - Igor, chislo - 5; 3 - id, name - Pasha, chislo - 3;

The task is to output chislo values ​​from larger to smaller in php, like this:

 Igor - 5 Pasha - 3 Tolya - 1 

Thank you in advance.

    1 answer 1

     $query = "SELECT * FROM `znacheniya` ORDER BY `chislo` DESC"; $res = mysql_query($query); while($row = mysql_fetch_assoc($res)){ echo $row[name].' - '.$row[chislo]; } // По поводу единственной строки с максимальным значением: $query = "SELECT * FROM `znacheniya` ORDER BY `chislo` DESC LIMIT 1"; $res = mysql_query($query); $row = mysql_fetch_assoc($res); echo $row[name].' - '.$row[chislo]; 
    • And if you print one of the largest values? - oOKomarOo
    • Look towards SELECT MAX () ... ----------- By the way, even with the first variant of the query, you will have the maximum value in the first line of the result. - Deonis
    • one
      I do not understand, I'm just still noob in php =) - oOKomarOo
    • > And if you display one of the largest values? SELECT MAX ( chislo ) FROM znacheniya` - Deonis
    • Thank you so much =) - oOKomarOo