PHP paging code, supporting the first 10 pages and the next 10 page pagination

Source: Internet
Author: User
Tags prev

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/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.