Change your MySQL code from this:
$sql = "SELECT * FROM TABLE";
To this:
$sql = "SELECT * FROM TABLE ORDER BY the_name_of_the_column_name_to_sort LIMIT 0,20";
The problem is you are not saying what column name will sort this when you say “Sort the biggest numbers from the database to be the first ones.” Which column has these numbers? Change the query example above and replace the_name_of_the_column_name_to_sort
with the actual name of the column you want to sort on.
The part that reads LIMIT 0,20
will return 20 items beginning from the first item; aka: 0. So you could increment/paginate the list by changing that to LIMIT 20,20
, LIMIT 40,20
and so on.
EDIT: From the comment left by the original poster:
It contains only numbers. It seems like this is sorting it after the 1 letter of the number.
Go into the database & make sure that column is an INT
value and not a text or VARCHAR
column. If it is a number it should sort numerically using the example I provided.