PHP实现翻页处理的类
PHP实例源代码:PHP实现翻页处理的类
class Page{
var $CountAll; //共有纪录数
var $CountPage; //每页显示记录数
var $Link; //显示 完整的分页信息
var $ForPage; //上一页
var $NextPage; //下一页
var $FirstPage; //第一页
var $LastPage; //最后一页
var $CurrPage; //第几页
var $PageNum; //共有多少页
var $Parameter; //参数
var $LimitNum; //不是统计全部记录,而是显示部分记录,例如共有100条记录,但是只统计显示前50条
function Page($sql, $num=30){
//初始化,统计记录数
$this->CountPage = $num;
global $mysql;
$sql = base64_decode($sql);
$result = $mysql->Query($sql);
if (0 != $mysql->AffectedRows()){
$row = $mysql->FetchArray($result);
$this->CountAll = $row[0];
}
else{
$this->CountAll = 0;
}
//print "共有 $this->CountAll
";
}
function ListPage($sql, $page=0,$sql_all,$other){
//查询,定义变量,获取数据
global $mysql;
//print "sql sql
";
if (isset($this->LimitNum) && $this->CountAll > $this->LimitNum){
$this->CountAll = $this->LimitNum;
}//更新总浏览记录数
$sql_src = $sql;
//if ($page > 0){
$sql = base64_decode($sql);
$sql_all = base64_decode($sql_all);
$sql_src = $sql;
//}
//echo $sql;
if (($this->CountAll % $this->CountPage) == 0)//统计共有多少页
$pagecount = (integer)($this->CountAll/$this->CountPage);
else
$pagecount = (integer)($this->CountAll/$this->CountPage)+1;
$this->ageNum = $pagecount;
if ($page > $this->ageNum)//如果页码超过页码总数则设为最大页码
$page = $this->ageNum;
if ($page $page = 1;
if ($this->CountAll == 0)
{
$this->CurrPage = 0;
}else{
$this->CurrPage = $page;
}
$first_start = ($page-1)*$this->CountPage;
$sql = $sql." limit ".$first_start.", ".$this->CountPage;
//print "2sql
";
$result = $mysql->Query($sql);
if (0 != $mysql->AffectedRows()){
$i = 0;
while($row = $mysql->FetchArray($result)){
$array[$i] = $row;
//print "name:".$array[$i][Name]."
";
$i++;
}
}
$sql = base64_encode($sql_src);
$sql_all = base64_encode($sql_all);
if ($pagecount >1){
if($page == 1){
$nextpage = $page+1;
$forpage = 1;
$this->Link = "";
$this->NextPage = "";
$this->LastPage = "";
}
else if(($page > 1)&&($page $forpage = $page-1;
$nextpage = $page+1;
$this->Link = "";
$this->ForPage = "";
$this->NextPage = "";
$this->FirstPage = "";
$this->LastPage = "";
}
else if ($page = $pagecount){
$forpage = $page-1;
$nextpage = 1;
$this->Link = "";
$this->FirstPage = "";
$this->ForPage = "";
}
}
else{
$this->Link = ' ';
}
return $array;//$array;
}
}
/***************
使用例子
include("class.config.php");
include("class.mysql.php");
include("class.page.php");
global $mysql;
$config = new Config;
$mysql = new TDatabase($config);
$query_all = "select count(*) from user";
$page_object = new Page($query_all,20);
//new Page('统计记录个数语句',每页记录个数)
if(empty($query_page))
$query_sql = "select * from user";
//注意这里的变量名必须为 $query_sql $query_page ,因为下一页的连接参数默认为 query_sql query_page
$list = $page_object->ListPage($query_sql,$query_page);
//ListPage('没有limit的前一部分,系统自动根据补齐',察看的页数)
$page_object->Parameter = '&action=view';
//这是传送的Url 所带的其它参数,如果有就修改变量 Parameter ,系统自动将她补在后面
//显示数据
for ($i=0;$iCountPage;$i++)
print $list[$i][ID]."->".$list[$i][UserName]."
";
//返回的数据为二维哈西(关联)数组,一维为纪录的标识ID号,二维为哈西(关联)数组,取值标识建议采取用数据库中字段名的方法,例如list[0][UserName]。
//显示其他相关数据
echo $page_object->CountAll;//纪录总数
echo $page_object->CountPage;//每页显示数据个数
echo $page_object->Link;//显示完整的分页信息
echo $page_object->FirstPage;//第一页
echo $page_object->NextPage;//下一页
echo $page_object->ForPage;//上一页
echo $page_object->LastPage;//最后一页
echo $page_object->CurrPage;//第几页
echo $page_object->PageNum;//共有多少页
$mysql->DatabaseClose();
****************/
?>

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

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

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

Undress AI Tool
Undress images for free

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

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1
Powerful PHP integrated development environment

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.