Data from the database of the last 10 newest

I just want to show that the last 10 or 30 depends on the list, if there is big data, search on the net, but all by correcting I can only see the 1st not the newest.

$sql = "SELECT id, tag, count FROM url ORDER BY id, tag, count ASC LIMIT 1";

      

I am testing with 2 data in a database and want to display the last one, but all the time it shows the oldest (first data), I also changed ASC and DESC, both time results are the same.

+3


source to share


3 answers


Use this:



$Query = "SELECT id, tag, count FROM url ORDER BY id DESC LIMIT 10"

      

+1


source


Try it.

Order by ID using "DESC" it gets the last before the first and limits 0.10 means it displays the last 10 records



$sql = "SELECT id, tag, count FROM url ORDER BY id DESC LIMIT 0 10"

      

+4


source


Modify your query and try this:

$Query = "SELECT id, tag, count FROM url ORDER BY id DESC LIMIT 10";

      

0


source







All Articles