php mysql paging implementation code_PHP tutorial
This is a relatively perfect paging class. It supports form input jump and select jump paging. It also supports offset paging for the previous 10 pages and the next 10 pages. */
This is a relatively perfect paging class. It supports form input jump and select jump paging. It also supports offset paging for the previous 10 pages and the next 10 pages.
*/
class wind_page
{
var $page;
//The current page
var $total;
//Total number of records
var $totalpage;
//Total page tree
var $pagesize;
//Number of items displayed on each page
var $offset;
//Offset
var $result;
//Record collection
var $thispage;
//Total number of records //Total number of records //Total number of records
var $link;
//Connect (record $_get variable)
var $bar_mun;
//Number of pages displayed by bar
var $starttime;
//Start time
var $bar_last;
//The number of continuous pages of the navigation bar
var $bar_mid;
//Navigation bar middle page
var $minpage;
//Navigation bar minimum page
var $maxpage;
//Maximum page of navigation bar
var $key;
//Identify pagination (used to distinguish multiple paginations on one page)
var $style;
//Output style
var $pre_page_char;
//Previous page
var $pre_page_image;
//Previous page graphics
var $pre_page_char_color;
//Font color of previous page
var $next_page_char;
//Next page
var $next_page_image;
//Next page graphics
var $next_page_char_color;
//Next page font color
var $pre_groud_char;
//Turn up the middle page
var $pre_groud_char_color;
//Number font color of the middle page when turning up
var $next_groud_char;
//Turn down the middle page
var $next_groud_char_color;
//Number font color when turning down the middle page
var $first_page_char;
//Home
var $first_page_char_color;
//Home page font color
var $last_page_char;
//Last page
var $last_page_char_color;
//Last page font color
var $html_page_val;
//html current page number value
Function wind_page($sql, $pagesize = 20, $bar_mun = 10, $style = 1,$this_page = 1,$html_page_val=1,$key = "") //Constructor ()
{
$this->starttime = microtime();
$this->pagesize = $pagesize;
//Number of items displayed on each page
$this->key = trim($key);
$this->bar_mun = $bar_mun;
$this->style = $style;
$this->html_page_val = $html_page_val;
//html current page number value
$this->bar_last = $bar_mun-1;
$this->bar_mid = floor($bar_mun/2);
$this->sql = $sql;
$result = mysql tutorial_query($this->sql);
$this->total = mysql_num_rows($result);
//Total number of records
$this->totalpage = ceil($this->total/$this->pagesize);
//Total number of pages
//$this->page = ceil($_get[$this->key."page"]);
$this->page = $this_page;
//现在所在页
if ($this->page == "" || $this->page < 1 || !is_numeric($this->page))$this->page = 1;
$this->page = min($this->page, $this->totalpage);
$this->thispage = $this->pagesize;
if ($this->page * $this->pagesize > $this->total) {
$this->thispage = $this->total-($this->page-1) * $this->pagesize;
};
$this->sql .= " limit ".($this->pagesize * ($this->page-1)).", ".$this->pagesize;
//开始读取的条数
//echo "
";
$this->result = mysql_query($this->sql);
$this->getvar();
$this->pre_page_char = "上一页";
$this->pre_page_image = "";
$this->next_page_char = "下一页";
$this->next_page_image = "";
$this->pre_groud_char = "上一组";
$this->next_groud_char = "下一组";}
function getvar() //取得除page外的其他get变量
{
$this->link = "";
foreach($_get as $key => $vaule) {
if (strtolower($key) !== $this->key."page") $this->link .= "&$key=$vaule";
}
}
function pre_page($color="#909090",$sign=0) //上一页
{
if ($this->page > 1) {
return "page-1).".html" class="ab">pre_page_char_color."">".$this->pre_page_char."";
} else
{
return "".$this->pre_page_char."";
}
}
function next_page($color="#909090",$sign=0) //下一页
{
if ($this->page < $this->totalpage) {
return "page+1).".html" class="ab">".$this->next_page_char."";
} else {
return "".$this->next_page_char."";
}
}
function pre_groud($char = "<<", $color = "#909090") //上一组
{
if ($this->page <= ($this->bar_mid+1)) {
return "".$this->pre_groud_char."";
//return $this->pre_groud_char;
} else {
$pre_gpage = ($this->page-$this->bar_mid < 0)?1:
$this->page-$this->bar_mid;
return "".$this->pre_groud_char."";
}
}
function next_groud($char = ">>", $color = "#909090") //下一组
{
if (($this->totalpage-$this->page) <= ($this->bar_mid-1)) {
return "".$this->next_groud_char."";
} else {
$next_gpage = ($this->page+$this->bar_mid < $this->totalpage)?$this->page+$this->bar_mid:
$this->totalpage;
return "".$this->next_groud_char."";
}
}
function mun($lcolor = "#ff6633", $acolor = "#ff6633", $left = " ", $right = " ") //数字导航栏
{
$link = "";
$this->minpage = ($this->page-$this->bar_mid < 1) ? 1:($this->page-$this->bar_mid);
$this->maxpage = $this->minpage+$this->bar_last;
if ($this->maxpage > $this->totalpage) {
$this->maxpage = $this->totalpage;
$this->minpage = ($this->maxpage-$this->bar_last < 1) ? 1: $this->maxpage-$this->bar_last;
}
for($i = $this->minpage; $i <= $this->maxpage; $i++)
{
/* 循环输出页码 */
$i = sprintf("%02d",$i);
//不足两位的前面补0
$char = $left.$i.$right;
//导航条左右两边加窄
if ($i == $this->page)
{
/* 假如是当前页则不加链接 */
$link.= "".$char."";
}
else
{
//$link .= "key."page=".$i.$this->link."" >".$char."";
$link.= "".$char."";
//关键把$link 加在新资料加入之后
}
}
echo "
";
return $link;
}
function jump_bar($class = "jump_bar") //下拉跳转
{
$link = "";
return $link;
}
function mun_bar() //整条数字导航栏 [<<][<][01][02][03][04][05][06][07][08][09][10][>][>>]
{
//return $this->first_groud().$this->pre_groud().$this->pre_page().$this->mun().$this->next_page().$this->next_groud().$this->last_groud();
return $this->pre_groud()." ".$this->pre_page().$this->mun().$this->next_page()." ".$this->next_groud();
}
function page_button()
{ //整条数字导航栏 [<][01][02][03][04][05][06][07][08][09][10][>]
//return $this->first_groud().$this->pre_groud().$this->pre_page().$this->mun().$this->next_page().$this->next_groud().$this->last_groud();
return $this->pre_page('#909090',1).$this->mun().$this->next_page('#909090',1);
}
function total_bar($coloro = "#000000", $colorn = "red") //统计数字 页次:1/4310 每页:20 共计:4310页 本页:20
{
return "页次:$this->page/$this->totalpage 每页:$this->pagesize 共计:$this->totalpage页 本页:$this->thispage";
}
// 整条导航栏
//页次:1/4310 每页:20 共计:4310页 本页:20 [<<][<][01][02][03][04][05][06][07][08][09][10][>][>>]
function page_bar($coloro = "#000000", $colorn = "red") {
return "".$this->mm_jumpmenu();
".$this->total_bar()."
".$this->mun_bar()."
".$this->jump_bar()."
}
function taketime($color = "#000000") //计算执行时间
{
return "本页执行时间".abs((microtime()-$this->starttime) * 1000)."毫秒";
}
Function style() //Output paging style
{
$style_num = $this->style;
If ($this->totalpage != 0) //If the total number of pages = 0, it means no paging
{
switch($style_num) {
case 1:
return $this->page_bar();
//Page: 1/4310 Each page: 20 Total: 4310 pages This page: 20 [<<][<][01][02][03][04][05][06][07 ][08][09][10][>][>>]
break;
case 2:
echo $this->mun_bar();
//The entire digital navigation bar [<<][<][01][02][03][04][05][06][07][08][09][10][> ][>>]
break;
case 3:
echo $this->page_button();
//The entire digital navigation bar [<][01][02][03][04][05][06][07][08][09][10][>]
break;
}
}
}
Function mm_jumpmenu() //Jump of web page special effects
{
//window.open(selobj.options[selobj.selectedindex].value,targ);
return "![]()
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
What's New in Windows 11 KB5054979 & How to Fix Update Issues4 weeks ago By DDDHow to fix KB5055523 fails to install in Windows 11?3 weeks ago By DDDInZoi: How To Apply To School And University1 months ago By DDDHow to fix KB5055518 fails to install in Windows 10?3 weeks ago By DDDWhere to find the Site Office Key in Atomfall1 months ago By DDD![]()
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

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

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

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.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.
