Page 1 of 1
Multi pages with PHP ?
Posted: Sun Nov 22, 2009 2:06 am
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
Re: Multi pages with PHP ?
Posted: Sun Nov 22, 2009 12:00 pm
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.
Re: Multi pages with PHP ?
Posted: Sun Nov 22, 2009 3:29 pm
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.