Multi pages with PHP ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Mds
Forum Contributor
Posts: 110
Joined: Tue Apr 22, 2008 8:56 pm
Contact:

Multi pages with PHP ?

Post by Mds »

Hi.
I have many rows in my database and I'm gonna show them like the image that I've attached.
Could you please guide me whether there is a script for it ?
Thanks
Attachments
multi pages.png
multi pages.png (851 Bytes) Viewed 165 times
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

Re: Multi pages with PHP ?

Post by MicroBoy »

I never tried to do it and at the moment I don't know how to do it, I just know that if you search in google for Pagination you will find many results about that.
User avatar
morris520
Forum Commoner
Posts: 60
Joined: Thu Sep 18, 2008 8:56 pm
Location: Manchester UK

Re: Multi pages with PHP ?

Post by morris520 »

First of all, I don't know there's an existing code to do this. This is a technique called 'page splitting' or sth similar.

What you are trying to do is to split 1,000 rows by 50 rows per page, which then gives 20 pages in total. It's not hard to do so if you know how to write PHP.

I am sharing an idea to approve this by only PHP form
1 by defining how many rows you want to put on a page, load those rows from DB by 'limit your_row' clause.
2 echo out a link that when it is clicked, the page number is passed as a parameter to tell the row numbers to be loaded on the next page.e.g. <a href="?page=<?=($current+1);?>">page $current</a>
3 to declare the total page number, just do it simply, though not most efficiently. Call a query to count the total rows and divide it by your $rows_per_page and round it to a Integer.

Hope this helps
If you need a sample do contact me by email.
Post Reply