MYSQL Query results in pages

From: Date: Thu, 24 Jun 2004 19:26:50 +0000
Subject: MYSQL Query results in pages
Groups: php.general 
Request: Send a blank email to php-general+get-188995@lists.php.net to get a copy of this message
Hi. I want to query some data in MYSQL and show the results in page order in some fashion (ORDER BY ...) I've been using the LIMIT sentence like this LIMIT offset, max_per_page so if max_per_page = 5 then the first time the sentence will be "LIMIT 0, 5", in page 2 "LIMIT 5,5" and so no. My problem is how to calculate how many rows the result returned. By now, the first time I'm querying without the LIMIT sentenced, and then store mysql_num_rows() to know have many pages there will be (i.e. maxrows = mysql_num_rows()/5). Is this right? Is there other efficent way to do it? What about if data changes (i.e. new records are added) while the user browses through pages? Thanks!

« previous php.general (#188995) next »