Quote:
Originally Posted by gilgalbiblewhee
But if I want to lay out the following pages 10 at a time then is this still good?
|
It is if you have some sort of incremental ID by which you can order them. For instance, if you are using an autonumber as the primary key for the table, then you can do something like:
Code:
SELECT TOP 10 * FROM mytable WHERE myid > lastid
where "lastid" is the highest ID that you retrieved that last time you pulled the records.
For instance, the "next" and "prev" links on your third page might look something like:
Code:
<a href="mypage.php?lastid=34>Previous page</a>
<a href="mypage.php?lastid=34>Next Page</a>
Then, your SQL statements would look something like:
Code:
nextSQL = "SELECT TOP 10 * FROM mytable WHERE myid > ".$_GET['lastid']." ORDER BY myid"
prevSQL = "SELECT TOP 10 * FROM mytable WHERE myid < ".$_GET['lastid']." ORDER BY myid DESC"