search
Homephp教程PHP源码php mysql网页分页代码

在php+mysql数据库的分页代码中比以前的asp,asp.net相对来就容易很多,因为mysql支持limit,0,N这样就可以轻松快速的获取要读取的记录,好下面来看实例

<script>ec(2);</script>
 代码如下 复制代码

function getpage ($talbe,$choose,$url){
 global $page,$db,$sortname;
 $query=$db->query("select * from $talbe $choose");
 $total=$db->num_rows($query);
 $totalpage=ceil($total/25);
 $nextpage=$page+1;
 $uppage=$page-1;
 if($nextpage>$totalpage)$nextpage=$totalpage;
 if($uppage  $showpage="共有$total条记录,共$totalpage页,当前为第$page
                          上一页下一页◇";
    return $showpage;
}
function reto($msg,$url=''){
 global $comeurl;
 if(!$url)$url=$comeurl;
 return "


                     

                       

                     

                   

                         
                       
";
}

通过上页的代码我们可以看出php分页原创很简单,只要get[page]页面,当前页,然后再用$page*$pagesize以开始,后以$pagesize为结束就OK了。mysql语句为 $sql ="Select * from t limit $page*$pagesize,$pagesize";

本站原创教程,转载注明来源www.111cn.net

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)