Adrian,Is there a library of some sort to batch queries? I mean, to have something like first, second, third, etc. 10 rows of 250. Like,
Records (x - x) out of x << View Previous 10 - View next 10 >>
Any ideas/pointers? I don;t even know if batching is
the right name.
I know exactly what you're talking about and if there is a library, I would definitely like to know about it. What we currently do at my work to this end is a combination of queries and CGI parameters (using MySQL and Perl). One query counts the total number of possible rows, then using that number and info provided in the query (with suitable defaults, such as going to the first page if no page is specified) the links to other pages is built. The second query actually gets the info for just the relative rows using "... limit x,y". I don't know if this mysql specific or general SQL. Example:
<?php
if (!$page) $page = 0;
# $record_count = "select count(*) from myTable where condition=1" $page_size = 10; $max_page = ciel($record_count / $page_size) - 1; $start_record = $page * $page_size;
# while ($record = "select * from myTable where condition=1 limit $start_record, $page_size")
{
displayRecord($record);
}
if ($page > 0) { ?><a href="<?= $PHP_SELF ?>?page=<?= $page - 1 ?>">Previous Page</a><br /><?php }
if ($page < $max_page) { ?><a href="<?= $PHP_SELF ?>?page=<?= $page + 1 ?>">Next Page</a><br /><?php }
?>
Obviously pseudocode, don't expect it to run right out of the box. :) But it should give you an idea.
Jacob
____________________
BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
