Simple sample code sharing for PHP paging query (picture)
This article mainly introduces the simple implementation code of phppaginationquery in detail. It has certain reference value. Interested friends can refer to it
Regarding php, I have learned a lot recently. The teacher told us that what we are learning now are all the core parts of php, so I paid more attention and practiced it a few more times. It is relatively easy to understand, no It was so difficult when I first started studying. To sum up, I feel that mentality is the most important thing. At the beginning, it was a question of mentality. Considering all aspects of the problem, I couldn’t calm down, and it has been many years since I sat down to study hard. I feel like I can't sit still. After a period of rest, including a period of time at home during the Chinese New Year, my mentality has changed a lot after returning. I feel that learning is not so boring anymore. Instead, I feel like I met someone many years ago. Mathematics problems are something that I especially want to overcome.
There are a lot of complaints, haha. The main thing I learned this morning was paging query: if there is a lot of data, it will look a lot when displayed on one page, and it will look very tiring. Then we use paging, which has been written before, and it looks like It's relatively clear. What we learned today is paging query. It's relatively simple. It just adds a query condition on the basis of paging. This time the chinastates table is used:
The first three columns are mainly used, namely the region code, region name and parent code. When performing paging queries, please note that get is used to obtain elements. When we perform paging queries, we will see the title bar displayed as shown in the figure:
It will be more troublesome if you use post to obtain it. In this case, you need to modify it on the new page and write the third condition in the brackets. In the code identification, There are annotations, and the results are also displayed in the uploaded pictures. The query is "medium", and then I see the second page. There are no problems
<body> <h1>分页查询</h1> <?php include("DADB.class.php"); $db=new DADB(); $tj= " 1=1 "; $area=""; if(!empty($_GET["area"])) { $area=$_GET["area"]; $tj=" areaname like '%{$area}%'"; } ?> <form action="fenyechaxun.php" method="get" > //这里用的是get 来获取 <p>地区名称:<input type="text" name="area" value="<?php echo $area; ?>"/> //这里如果没有传入value值 如果查询内容的数量比较多, 那么在第二页的时候将与需要查询的内容不符 <input type="submit" value="查询"/></p> </form> <table border="1" cellpadding="0" cellspacing="0" width="100%"> <tr> <td>地区代号</td> <td>地区名称</td> <td>父级代号</td> </tr> <?php include("page.class.php"); $sqg="select count(*) from chinastates WHERE {$tj}"; //因为是需要查询,所以 select语句都要有条件 $arg=$db->Query($sqg); $page=new page($arg[0][0],20); //如果前面用的是post 那么这里 可以改为new page(, , "areaname='{$area}'" ) $sql="select * from chinastates where {$tj}" .$page->limit; $arr=$db->Query($sql); foreach($arr as $v) { echo"<tr> <td>{$v[0]}</td> <td>{$v[1]}</td> <td>{$v[2]}</td> </tr>"; } ?> </table> <p> <?php echo $page->fpage(); ?></p> </body>
The above is the detailed content of Simple sample code sharing for PHP paging query (picture). For more information, please follow other related articles on the PHP Chinese website!

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

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 a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

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, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.
