Jump to content

cylcing through mysql entries with PHP


Liquid Fire

Recommended Posts

I am looking to cylce through X amount of returned entries from a mysql table displaying X at a time.  Baically what forums do.  example:

I have 100 new item and what to display 10 per page, how would I create the link to display the next 10 and reload that same page with those next 10 entries?
Link to comment
https://forums.phpfreaks.com/topic/28126-cylcing-through-mysql-entries-with-php/
Share on other sites

In a nutshell:

[list]
[*]Start your page with something like [tt]$offset = $_GET['offset'][/tt]
[*]In your MySQL query include something like [tt]"limit = {$offset},10"[/tt]
[*]At the top of your page, write something like [tt]$next10 = $offset + 10;[/tt] and [tt]$last10 = $offset - 10;[/tt]
[*]At the bottom of your page, print links something like [tt]"<a href=\"thispage.php?offset={$next10}\">Next</a>"[/tt] and [tt]"<a href=\"thispage.php?offset={$last10}\">Previous</a>"[/tt]
[/list]

That should cover it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.