eating mySQL result rows 1 by 1.. a better way?

From: Date: Thu, 21 Mar 2002 15:54:12 +0000
Subject: eating mySQL result rows 1 by 1.. a better way?
Groups: php.general 
Request: Send a blank email to php-general+get-89520@lists.php.net to get a copy of this message
Hello, On my site I paginate query results by limiting rows output to a value, say LIMIT, and then the 2nd, 3rd pages run the same query with $skip=LIMIT, $skip=(LIMIT*2) value posted back. I use the following code to "skip" these result rows, which is just fetching the next row to an unused array. //if there are rows to skip if ($result_rows > $rows_to_skip) { while ( $rows_to_skip ) { // eat a row mysql_fetch_array($result); $rows_to_skip--; $total_results_shown++; } } Can I make this more efficient? Is there a way to eliminate this data before it leaves the mySQL server (and would it be faster)? If it makes any difference the average result row is probably around 40-50 bytes but some of these queries can return up to 850 rows.. Steve -- steve@mrclay.org ** http://mrclay.org

« previous php.general (#89520) next »