|
I assume you're using a scripting language like PHP or Perl to accomplish this?
When MySQL 4+, you can use "select sql_calc_found_rows, field1, field2..." where 'sql_calc_found_rows' lets you make another query ("select found_rows()") that returns the total number of rows.
So what you have to do is select the data you want, and then have a "limit" statement at the end of your query - for example, "limit $offset, 4". The $offset is by default set to 0. If you find out that the total # of rows that would have been returned (without the limit - you get this from the 'found_rows()' query) is greater than 4, then you need to print a "Next" link where you increment the $offset variable by 4. So, the first time the query is run, the limit statement will be "limit 0, 4" (select the first 4 rows). When someone clicks on 'next', it will be "limit 4, 4" (select rows 5-8).
For previous, just check of $offset is greater than 0. If it is, print a "Previous" link that sets $offset to $offset - 4;
Good luck!
__________________
I store my recipes online (the way nature intended) at Please login or register to view this content. Registration is FREE
|