April 2017
SunMonTueWedThuFriSat
      1
2345678
9101112131415
16171819202122
23242526272829
30      

Calendar Calendar

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

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

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

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

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

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

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

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

» PHP Script to Extract Email Address from any text
Fri 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

View previous topic View next topic Go down

pagination

Post  scvinodkumar on 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

View user profile http://solutions.aforumfree.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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