输出记录的时候加个变量ID就可以了 ID与查询的具体内容无关
$sql = "select";
$result = mysql_query($sql);
$id=1;
while($row=mysql_fetch_array($result)){
echo $id." ".$row["name"];
$id++;
}
类似这种格式 ID只与查询出来的记录的条数有关
$result = mysql_query($sql,$con);
mysql_data_seek($result, 2);
while ($rs = mysql_fetch_array($result)){
....
}
mysql_close();
SELECT @rownum:=@rownum+1 AS rownum, tab.*
FROM (SELECT @rownum:=0) r, tab;