SELECT * FROM (select id,name from table order by id desc limit 0,3) as tbl order by tbl.id asc
mysql 正序 显示最后几条
SELECT * FROM (select id,name from table order by id desc limit 0,3) as tbl order by tbl.id asc2012-06-12
<?php//第一步 获取id和name的内容,取最后10条$sql888 = mysql_query("select id,name from 某表名 ORDER BY id DESC LIMIT 10");//第二步,由于 mysql是一条条读取,所以要while循环来读完,存入数组$qq999 里$qq999 = array();while($array = mysql_fetch_array($sql888)) { $qq999[] = $array;}//第三步 用php的 array_reverse()反置命令,把数组顺序反置 存入变量$my_ok里$my_ok = array_reverse($qq999);//第四步 foreach()循环输出数组 foreach($my_ok as $value999) { ?> <tr> <th width="140" align="left" bordercolor="#FFFFFF" bgcolor="#CCCCCC" scope="col"><?php print_r($value999['id']); ?> </th> <th width="140" align="left" bordercolor="#FFFFFF" bgcolor="#CCCCCC" scope="col"><?php print_r($value999['name']); ?> </th> </tr><?php } ?>4步完成,复制代码即可,
2018-07-20