Link to record number

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
packito
Forum Newbie
Posts: 20
Joined: Mon May 19, 2003 1:53 pm

Link to record number

Post by packito »

Hey everybody!
I don't know how to put this question...

I bet everybody has noticed that when we search for something on the internet, using google or other search machine, we can see at the bottom of each search result page something like this

[1] [2] [3]... next | previous

where each number is a link to a specific page of the search's recordset. Now, I've already done the "next" and "previous" links, but can anyone give me a tip on how to implement links using the numbers?

Thanks!

PS: i was not very clear, but i hope you understand me... :?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Get the total num of rows and then calculate the total number of pages with

Code: Select all

<?php
$total_pages = ceil($total_rows/$max_items_per_page)
?>
Now you can loop through $total pages building up a 1 | 2 | 3 type link.
Last edited by McGruff on Wed Aug 10, 2005 5:40 pm, edited 1 time in total.
packito
Forum Newbie
Posts: 20
Joined: Mon May 19, 2003 1:53 pm

Post by packito »

Eheh, i solved the problem just few minutes after i wrote this topic.
And yes, I used the same solution proposed by McGruff.

Thanks for the tip anyway, McGruff! :)
Post Reply