Reading Mysql database in groups of 10

Go To StackoverFlow.com

0

I need to be able to read the contents of a Mysql database 10 records at a time so that i can display the first 10 and then when the user click on page 2, i need to be able to read the second block of 10 records with out the first 10, etc, etc

this is what im using to read the first 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()); 
2012-04-04 20:25
by connor.p


1

Isn't it just

$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;")

For the next 10? Then

$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;")

For the 10 after that?

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

2012-04-04 20:28
by Almo
fantastic, thank you very much, it worked perfectl - connor.p 2012-04-04 20:30
Sure, no problem. : - Almo 2012-04-04 20:30
ill be marking it as the answer asap : - connor.p 2012-04-04 20:30
Ads