id name
1 A
2 B
3 C
4 D
5 E
显示
3 C
4 D
5 E 求语句
第1个回答 2012-06-12
SELECT * FROM (select id,name from table order by id desc limit 0,3) as tbl order by tbl.id asc本回答被网友采纳
第2个回答 2018-07-20
<?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 } ?>
//第一步 获取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步完成,复制代码即可,