V
V
Valery Gutin2018-05-24 15:30:57
MySQL
Valery Gutin, 2018-05-24 15:30:57

Extracting records from a table with sorting?

How to display records not in order, but by rank value.
For example, there are 3 products, A has rank = 20, B = 10, and C = 40.
It needs to be displayed in ascending order in this case: B, A, B
Here is what is:

$sql = $mysqli->query("SELECT * FROM goods");

  foreach ($sql as $item) {
    echo $item["name"];
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2018-05-24
@alohamneploha

SELECT * FROM goods ORDER BY rank ASC

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question