PHP paging code, supporting the first 10 pages and the next 10 page pagination
function Multlink ($currentPage, $totalRecords, $url, $pageSize = 10)
{
Global $func _message;
if ($totalRecords <= $pageSize) return ";
$mult = ';
$totalPages = Ceil ($totalRecords/$pageSize);
$mult. = ' <div class= ' pages ' ><div class= ' nextprev ' > ';
if ($currentPage > 1)
{
$mult. = ' <a href= '. $url. ' Page= '. ($currentPage-1). ' " > Prev </a> ';
}
Else
{
$mult. = ' <span class= ' Nextprev ' > Prev </span> ';
}
if ($totalPages < 13)
{
for ($counter = 1; $counter <= $totalPages; $counter + +)
{
if ($counter = = $currentPage)
{
$mult. = ' <span class= ' current ' > '. $counter. ' </span> ';
}
Else
{
$mult. = ' <a href= '. $url. ' page= '. $counter. ' > '. $counter. ' </a> ';
}
}
}
ElseIf ($totalPages > 11)
{
if ($currentPage < 7)
{
for ($counter = 1; $counter < $counter + +)
{
if ($counter = = $currentPage)
{
$mult. = ' <span class= ' current ' > '. $counter. ' </span> ';
}
Else
{
$mult. = ' <a href= '. $url. ' page= '. $counter. ' > '. $counter. ' </a> ';
}
}
$mult. = ' <span>& #8230; </span><a href= '. $url. ' Page= '. ($totalPages-1). ' " > '. ($totalPages-1). ' </a><a href= "'. $url. ' page= '. $totalPages. '" > '. $totalPages. ' </a> ';
}
ElseIf ($totalPages-6 > $currentPage && $currentPage > 6)
{
$mult. = ' <a href= '. $url. ' page=1 ' >1</a><a href= '. $url. ' page=2 ' >2</a><span>&# 8230;</span> ';
for ($counter = $currentPage-3; $counter <= $currentPage + 3; $counter + +)
{
if ($counter = = $currentPage)
{
$mult. = ' <span class= ' current ' > '. $counter. ' </span> ';
}
Else
{
$mult. = ' <a href= '. $url. ' page= '. $counter. ' > '. $counter. ' </a> ';
}
}
$mult. = ' <span>& #8230; </span><a href= '. $url. ' Page= '. ($totalPages-1). ' " > '. ($totalPages-1). ' </a><a href= "'. $url. ' page= '. $totalPages. '" > '. $totalPages. ' </a> ';
}
Else
{
$mult. = ' <a href= '. $url. ' page=1 ' >1</a><a href= '. $url. ' page=2 ' >2</a><span>&# 8230;</span> ';
for ($counter = $totalPages-8; $counter <= $totalPages; $counter + +)
{
if ($counter = = $currentPage)
{
$mult. = ' <span class= ' current ' > '. $counter. ' </span> ';
}
Else
{
$mult. = ' <a href= '. $url. ' page= '. $counter. ' > '. $counter. ' </a> ';
}
}
}
}
if ($currentPage < $counter-1)
{
$mult. = ' <a href= '. $url. ' Page= '. ($currentPage + 1). ' " class= "Nextprev" > Next page </a> ';
}
Else
{
$mult. = ' <span class= ' nextprev ' > next page </span> ';
}
$mult. = ' </div></div> ';
return $mult;
}
<br/>
. pages {<br/>
Float:left;<br/>
margin:3px 0 5px 10px;<br/>
Font-size:12px;<br/>
}<br/>
. pages Span.nextprev {<br/>
border:1px solid #5CB711; <br/>
Color: #999999; <br/>
}<br/>
. pages Span.current {<br/>
-moz-background-clip:border;<br/>
-moz-background-inline-policy:continuous;<br/>
-moz-background-origin:padding;<br/>
Background: #5CB711 None repeat scroll 0 0;<br/>
border:1px solid #5CB711; <br/>
Color: #FFFFFF; <br/>
Font-weight:bold;<br/>
}<br/>
. pages A.nextprev {<br/>
Font-weight:bold;<br/>
}<br/>
. pages A,. pages a:visited {<br/>
border:1px solid #5CB711; <br/>
Color: #5CB711; <br/>
Text-decoration:none;<br/>
}<br/>
. pages a,. pages span {<br/>
-moz-background-clip:border;<br/>
-moz-background-inline-policy:continuous;<br/>
-moz-background-origin:padding;<br/>
Background: #FFFFFF None repeat scroll 0 0;<br/>
Display:block;<br/>
Float:left;<br/>
Margin-right:0.1em;<br/>
Padding:0.2em 0.5em;<br/>
}<br/>