Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple question...

Status
Not open for further replies.

alan123

MIS
Joined
Oct 17, 2002
Messages
149
Location
US
This should be a simple question, how I can display mysql data on the browser page by page(one page has multiple data corresponding to one record in mysql, sorted by ID for example), it has "previous" and "next" link on that page, and on the first/last page the link can be hidden. anyone can give me some clue? thanks.
 
You have to make use of MySQL's "LIMIT" clause in SELECT statements. If a SELECT query would return 1000 records, the LIMIT clause can tell MySQL to return rows 201-300, for example. This is documented in the MySQL online documentation on the page for the select statement:
In PHP, you pick a default page size, the number of records to display at a time. For the sake of argument, let's say we're going to display 25 records.

The script expects a GET-method input named "page" to tell it which set of 25 records to display. If it is not told which page to display, it assumes the first 25 records.

Each page of output will display a link back to the script it self, each like:

<a href=&quot;thescript.php?page=somenumber&quot;>

That somenumber will be the current page minus one (for a &quot;previous&quot; link) or the current page plus one (for a &quot;next&quot; link&quot;). Since the script knows which set of records to display, it is pretty easy to not display the &quot;Previous&quot; link

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top