开发者

How to make a query which gets and lists data from the last entry?

开发者 https://www.devze.com 2023-01-17 12:46 出处:网络
How do you make a query which gets data and lists it from the last entry in order of the ID adding it onto the code shown below,

How do you make a query which gets data and lists it from the last entry in order of the ID adding it onto the code shown below,

Example which needs add on,

$data_table = "posts";
$per_page = 8;
$start = $_GET['start'];
$query = mysql_q开发者_StackOverflow社区uery("SELECT *
                        FROM $data_table 
                       LIMIT $start,$per_page") or die(mysql_error());

Any code examples and Information would be useful, thanks.


You need to specify an ORDER BY clause:

$query = mysql_query("SELECT *
                        FROM $data_table 
                    ORDER BY id DESC
                       LIMIT $start,$per_page") or die(mysql_error());

If there's no ORDER BY clause, there's no guarantee about data order.

0

精彩评论

暂无评论...
验证码 换一张
取 消