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()); 
connor.p
  • 836
  • 9
  • 19
  • 29

1 Answers1

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

Almo
  • 14,789
  • 13
  • 64
  • 91