幾種不同風(fēng)格php分頁代碼(1/8)
Jun 08, 2016 pm 05:26 PMfunction outPege($ps教程,$page)
{
// $ps 累計信息數(shù) $page 當(dāng)前page數(shù) $max 列表的最大數(shù) $min 列表的最小值
$max????? = ($page >= 5)? $page+5:10;
if($max > $ps)$max =$ps;
$min????? =($page-5);
if($min
if($page>1)$pagelist = "首頁";
for($i=$min;$i
? $pagelist.= ($i!=$page)? "{$i}":"{$page}";
}
$pagelist.= ($page>=$ps)?'':"尾頁";
return $pagelist;
}
//方法二
/**
* 顯示分頁函數(shù)
* records總記錄數(shù),currentpage當(dāng)前頁數(shù),rows每頁記錄數(shù),listpage頁號列表長度。
*/
function showpage ($records,$currentpage,$rows=20,$listpages=7) {
if($records
if($rows
if($listpages
$action=$_SERVER['QUERY_STRING']; //得到地址欄中?后的內(nèi)容
if($action){ //將page=...的內(nèi)容去掉
$action=preg_replace("/&page[^&]*/","",$action);
$action=preg_replace("/page[^&]*&*/","",$action);
}
if($action)$action.='&';
$maxpage=ceil($records/$rows); //進(jìn)一法取整得到最大頁數(shù)。
$middlepage=floor($listpages/2); //舍去法取整得到要顯示的頁數(shù)的一半。
if($currentpage$maxpage)$currentpage=1;
$startpage=$currentpage-$middlepage;
if($maxpage-$currentpage
if($startpage
$endpage=$startpage+$listpages;
if($endpage>$maxpage)$endpage=$maxpage; //結(jié)束頁計算完成
if($currentpage!=1){
$pagestr="1 ";
}else{
$pagestr="1 ";
}

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

DJI has not confirmed any plans to introduce a new action camera yet. Instead, it seems that GoPro will get ahead of its rival this year, having teased that it will introduce two new action cameras on September 4. For context, these are expected to a

Implementing data paging and display optimization in Vue projects. In Vue projects, when a page needs to display a large amount of data, data paging and display optimization usually need to be performed to improve user experience. This article will introduce how to use Vue to implement data paging and display optimization. , and provide specific code examples. 1. Data paging Data paging refers to dividing a large amount of data into multiple pages according to certain rules and displaying them on the page. You can use the following steps to implement data paging in a Vue project: Define the data source. First, define a

php提交表單通過后,彈出的對話框怎樣在當(dāng)前頁彈出php提交表單通過后,彈出的對話框怎樣在當(dāng)前頁彈出而不是在空白頁彈出?想實現(xiàn)這樣的效果:而不是空白頁彈出:------解決方案--------------------如果你的驗證用PHP在后端,那么就用Ajax;僅供參考:HTML code

Almost a year has passed since DJI released the Osmo Action 4 (curr. $299 on Amazon). Since then, the company has focused on its other divisions, including new RS camera gimbals. On top of that, it has introduced various drones as well like the Avata

請問如何修改url某一參數(shù)的參數(shù)值呢?是要拆開了再拼回去嗎?那么請問如何修改url某一參數(shù)的參數(shù)值呢?是要拆開了再拼回去嗎?http://127.0.0.1/myo/newuser.php?mod=search&type=fastone比如現(xiàn)在我要修改mod=new要怎么做呢?------解決方案--------------------發(fā)送了請求

Insta360hasreleasedanewactioncamera,itssecondoftheyearaftertheInsta360X4(curr.$499.99onAmazon).Asexpected,thecompanyhasintroducedtheGo3S,anupgradedthatGo3thatadds4Kvideorecordingcapabilities.Specifically,whileInst

Everyone is looking forward to today's Windows 1123H2 release. In fact, Microsoft has just launched updates to the release preview, which is the closest channel before the official release stage. Known as Build 22631, Microsoft said they are rolling out the new rebranded chat app, phone link, and play together widgets that have been tested on other internal channels over the past few months. "This new update will have the same servicing branch and codebase as Windows 11 version 22H2 and will be cumulative with all newly announced features, including Copilot in Windows (preview)," Microsoft promises. Redmond officials further

GoPro has now introduced its annual action camera refresh. Unlike in recent years, the company has decided to release two models. However, it has not returned to 360-degree cameras, despite teasing this time last year that it would replace the Max wi
