PHP forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.
April 2024
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
282930    

Calendar Calendar

Latest topics
» Kabaddi, Kabaddi, Kabaddi, Kabaddi......PHP?
pagination EmptyFri Jul 22, 2011 1:37 pm by shyamsunder

» Thousands of Free PHP Scripts Recommended
pagination EmptyWed May 18, 2011 10:33 am by bizboy12

» PHP form validation problem?
pagination EmptyWed Jan 12, 2011 1:25 pm by simy202

» string wrap
pagination EmptySat Aug 02, 2008 2:06 pm by scvinodkumar

» retrieving current date rows
pagination EmptyTue Jul 15, 2008 3:25 am by scvinodkumar

» number in words
pagination EmptyTue Apr 29, 2008 3:10 pm by scvinodkumar

» Simple PHP Form Field Generator
pagination EmptyFri Apr 25, 2008 12:28 pm by scvinodkumar

» PHP password generator
pagination EmptyFri Apr 18, 2008 7:24 pm by scvinodkumar

» PHP Script to Extract Email Address from any text
pagination EmptyFri Apr 18, 2008 7:18 pm by scvinodkumar

Search
 
 

Display results as :
 


Rechercher Advanced Search

Affiliates
free forum
 


Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

pagination

Go down

pagination Empty pagination

Post  scvinodkumar Fri Apr 18, 2008 7:11 pm

<?php
$page = $_REQUEST['page'];
echo get_page_nav($page,20);
function get_page_nav($page_current, $page_total)
{
$ar_pages = array();
/* HTML-tag to select the current page */
$str_tag = 'strong';
/* Language strings */
$str_page_prev = 'previous';
$str_page_next = 'next';
/* String placed between the first and last page numbers */
$str_more = '..';
/* String to separate page numbers */
$str_d = ' - ';
/* URL for paging */
$str_url = 'index.php?page=%d';

/* The number of links to pages displayed before and after the current page. 1 2 (3) 1 2 */
$int_max = 2;
$cnt_new = $page_current;
$cnt_max = $page_current + $int_max;
$cnt_min = $page_current - $int_max;
/* Fix the maximum number of pages */
if ($cnt_max > $page_total)
{
$cnt_max = $page_total;
}
/* First page */
if ($cnt_min > 1)
{
$ar_pages[] = '<a href="'.sprintf($str_url, 1).'">1</a>';
$ar_pages[] = $str_more;
}
/* For each page number */
for ($i = 1; $i <= $page_total; $i++)
{
if ( ($i >= $cnt_min && $i <= $cnt_max) )
{
if ($i == $page_current)
{
$ar_pages[] = '<a href="'.sprintf($str_url, $i).'"><'.$str_tag.'>'.$i.'</'.$str_tag.'></a>';
}
else
{
$ar_pages[] = '<a href="'.sprintf($str_url, $i).'">'.$i.'</a>';
}
}
$cnt_new++;
}
/* The last page */
if ($cnt_max > 1 && ($page_current + $int_max) < $page_total)
{
$ar_pages[] = $str_more;
$ar_pages[] = '<a href="'.sprintf($str_url, $page_total).'">'.$page_total.'</a>';
}
/* Links to Next/Prev pages */
if ($page_current > 1)
{
$ar_pages[] = '<a href="'.sprintf($str_url, ($page_current - 1) ).'">'.$str_page_prev.'</a>';
}
if ($page_current < $page_total)
{
$ar_pages[] = '<a href="'.sprintf($str_url, ($page_current + 1) ).'">'.$str_page_next.'</a>';
}
return implode($str_d, $ar_pages);
}
?>

scvinodkumar
Admin

Posts : 40
Join date : 2008-01-30

https://solutions.aforumfree.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum