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!

output of data: Limiting 20 Entrys per Page, auto create the links

Status
Not open for further replies.

lukelukeluke

Technical User
Joined
Dec 23, 2003
Messages
117
Location
CH
Good Day,

I have a question to a DATA OUTPUT Function. We all know that its possible to limit the output of the database with that:
$sql = "SELECT * FROM test LIMIT 0,20"
Generally, thats working for me. If i activate this, i only see the first 20 entrys from the database.
What i can do also is: I can create 3 sites, first with "LIMIT 0, 20", second with: "21, 40", third with: "41, 60".
But what if i got more than 60 database entrys?

Is there a function to create these sites automatically? Lets say a function which counts the posts, and if it sees 160, it says 160/20 = 8 sites and it will loop a row of links at the bottom of the page which says 1, 2, 3, 4, 5, 6, 7, 8?

Thanks for youre ideas!

Greetings, lucas
 
You mentioned the solution for your problem yourself.
All you need is a counter for the pages to calculate the "offset". Increment the counter with a "next" link, decrement it with "previous". Make those links just appear when there are more records to display in the respective direction.
As for a packaged solution, I don't believe there is.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top