对不起,写错了,应该是:
我查询一个表的最后60条记录可以用
select * from table11 where userid=$userid order by id desc limit 60
但要在php上输出时,如何让最后一条记录是在最后一行?

while ($arr=mysql_fetch_row($result)){
echo" 
 <tr>
    <td width=\"10%\">$arr[13]</td>
<td width=\"18%\">$arr[12]</td>
<td width=\"7%\">$arr[11]</td>
<td width=\"7%\">$arr[10]</td>
<td width=\"5%\">$arr[9]</td>“}
时,最后一条记录是在第一行。

解决方案 »

  1.   

    select * from table11 where userid=$userid order by id limit 60
      

  2.   

    这样做:
    select * from (select * from table11 as a where userid=$userid order by id desc limit 60) as b order by id
      

  3.   

    mathematician(数学家),你的语句不行啊!!!!!
    zhoutm(阿勉) ,如果用总数减去60的话,我有10几万记录,会影响速度的
      

  4.   

    你的Mysql版本多少?支持子查询吗?
    语句没问题,我这里可以正确执行。
      

  5.   

    就不知道php语句能不能倒着输出?
      

  6.   

    3.23.44不支持子查询,的确有点麻烦,不过你说的‘倒着输出’的办法可行。返回的记录生成数组,比如array。可以使用php函数array_reverse(array,array)将之反向。array_reverse(array,array)
    返回元素次序反向之后的数组array.