Item Detail

96
Pagination Advanced (v. 1.0)
Category: Miscellaneous
About (in brief)
In Pagination you can distribute number of records on different pages and specify links so that user can go from one page to next page. Generally what user see is First, Previous, Next, Last links along with few page numbers like 1,2,3,4,5 and if he is on
Description
Calculating past and future dates in PHP 28 Jan 2011 basiccodes A nice article on how to calculate past and future dates in PHP is available at: http://www.the-art-of-web.com/php/strtotime/ Share Category: PHP Tags: Date Leave a Comment How to get a value from a table using functions and return count 27 Jan 2011 basiccodes How to get a value from a table using functions and return count: Write a simple query and pass the parameters: function somename($tablename, $colnam, $colvalue, $mode, $returncolnam) { Select $returncolnam from $tablenam where $colnam=$colval } Note: For $returncolnam you can also use array number starting from 0. Share Category: MySQL, PHP Tags: Database, Functions, Table, Value Leave a Comment How to search a column in MySQL with CSV records 27 Jan 2011 basiccodes When we search a column in MySQL we use where condition. When we have many records separated by a ‘,’ in a column then searching it becomes bit complex. We can search using like function. It will be clear by taking an example: Let say we have a record with value – 1,2,3,4,5,6,7,8,9,10,11,12 We want to search say 2. We can search it by using like but when we use it, it will return us this record and other records as well like where values of a column are: 5,10,15,20 or 8,9,10,11,12 i.e. there 2 appearing anywhere in a column. But we wanted results which have columns with 2 as a value not contained in some another number. For this, we can use IN. But when using IN we get results only
In Pagination you can distribute number of records on different pages and specify links so that user can go from one page to next page. Generally what user see is First, Previous, Next, Last links along with few page numbers like 1,2,3,4,5 and if he is on page 9 then something like 7,8,9,10,11 or 9,10,11,12,13 etc.

But what when there are large number of pages say 1000 and a user wants to go to page number 400 then according to simple pagination he can click on Page 5 then page 7 then 9 (when there are 5 pages being shown) and page 5 then 12 then 19 (when there are 15 pages being shown) etc. and this would take time to reach Page Number 400. So, in such cases we should display more pages also.

With this code you will be able to view more pages. Lets take an example. Say there are 10000 records and on each page 10 records are being shown. So, number of pages is 1000. Currently selected Page is 500. So, links shown will be of Page 1,2,3,497,498,499,500,501,502,503,998,999,1000 and pages between 3-497 and 503-998 range with some page number difference. Here, we have taken links to be shown = 3, that is why Page 1,2,3 are showing.

Pagination in PHP is easy and you can show advance pagination by following code. There are 4 files (don’t go to the number of files, separate files have been created so that you can easily understand the code), I could have combined it in 1 but 4 seems to be better.
Requirements
PHP & MySQL
Features
  • Easy to implement script
  • Can be easily modified
  • Shows the Pagination by calling a function
  • Can change number of records to be shown on a page
  • Can change number of links to show
  • Set Page URL
by kb0000
added on 5th Feb, 2011 13:59:16
modified on 5th Feb, 2011 13:59:16
Visited 5409 times
latest on 19th Aug, 2017 09:09:14
Download (Size 6855 bytes)
Downloaded 2205 times (1 Today)
latest on 17th Aug, 2017 01:11:49
View Ratings
Rated 1 times

Share the Name

Share |