sql语句查询后几行数据并倒着排列
$conn = mysql_connect("数据库地址","用户名","密码");
if(!$conn)
{
die("mysql conn failed");
}
else{
mysql_query("SET NAMES ‘utf8‘");
mysql_select_db("数据表",$conn);
if(!$conn)
{
die("database selected failed");
}
}
$startCount=x //x为从第几行查询,例如有30行数据,查询26-30并按30,29,28,27,26排列,则x=1;
$perNumber=y //y为查询的行数.例如上边的y=5;
$sql="select B from A where 1 order by auto desc limit $startCount,$perNumber";
$result=mysql_query($sql,$conn);
while ($row=mysql_fetch_array($result)) {
echo "$row[B]"; //循环显示数据库的内容
}
刚入门,如有错误请高手指出!!!