0

我需要能够一次读取 Mysql 数据库 10 条记录的内容,以便我可以显示前 10 条,然后当用户单击第 2 页时,我需要能够读取第二块 10 条记录前 10 个等

这就是我用来阅读前 10 个的

$result = mysql_query("SELECT id FROM general_thread WHERE id_topic = $id");
$num_rows = mysql_num_rows($result);


$result = mysql_query("SELECT id, user_message, user_created, user_id, user_posts, user_rank, date_created FROM general_thread WHERE id_topic = $id ORDER BY id DESC
LIMIT 10;") 
or die(mysql_error()); 
4

1 回答 1

1

不只是

$result = mysql_query("SELECT id, user_message, user_created, user_id, user_posts, user_rank, date_created FROM general_thread WHERE id_topic = $id ORDER BY id DESC LIMIT 10, 10;")

下一个10?然后

$result = mysql_query("SELECT id, user_message, user_created, user_id, user_posts, user_rank, date_created FROM general_thread WHERE id_topic = $id ORDER BY id DESC LIMIT 20, 10;")

之后的10个?

http://php.about.com/od/mysqlcommands/g/Limit_sql.htm

于 2012-04-04T20:28:00.977 回答