php文章列表分页代码怎么写?
$sql = "SELECT * FROM `links` WHERE `subdomain` != '' ORDER BY id desc LIMIT 100";<br />$rows = $db->getData($sql);<br />foreach($rows as $row)<br />{<br /> echo '<li><a href="http://'.$row['subdomain'].'.abc.com/" title="'.$row['title'].'">'.$row['title'].'</a></li>';<br />}<br />
<br />class CCustomWidgets {<br /> public static function Pager($totalPages, $pageNumber, $pageSize, $url, $displayNumber = 6) {<br /> $baseUrl = (strpos($url, "?") === false) ? $url.'?page=' : $url.'&page=';<br /> $pager = '<div class="pager"><ul>';<br /><br /> $prevPage = $pageNumber - 1;<br /> if($prevPage > 0){<br /> $pager .= '<li><a href="'.$baseUrl. $prevPage.'"><span class="pager-previous">??????é??</span></a></li>';<br /> }<br /><br /> if($totalPages - $pageNumber < $displayNumber) {<br /> $displayStart = ($totalPages >= $displayNumber) ? ($totalPages - $displayNumber + 1) : 1;<br /> $displayEnd = $totalPages;<br /> }else{<br /> if($pageNumber % $displayNumber){<br /> $displayStart = floor($pageNumber / $displayNumber) * $displayNumber + 1;<br /> $displayEnd = (floor($pageNumber / $displayNumber) + 1) * $displayNumber;<br /> }else{<br /> $displayStart = (floor(($pageNumber / $displayNumber) - 1)) * $displayNumber + 1;<br /> $displayEnd = (floor($pageNumber / $displayNumber)) * $displayNumber;<br /> }<br /> }<br /><br /><br /> for(; $displayStart <= $displayEnd; $displayStart++) {<br /> $pager .= '<li><a href="'.$baseUrl.$displayStart.'"><span '.(($pageNumber == $displayStart) ? 'class="active"' : '').'>'.$displayStart.'</span></a></li>';<br /> }<br /> if($pageNumber < $totalPages){<br /> $pager .= '<li><a href="'.$baseUrl. ($pageNumber + 1) .'"><span class="pager-next">??????é??</span></a></li>';<br /> }<br /> $pager .= "</ul></div>";<br /> return $pager;<br /> }<br />}<br /><br />