关于PHP的分页有关问题
关于PHP的分页问题
本人是新手,麻烦大神们教我怎么用PHP完成查看数据中的分页功能,谢谢
------解决方案--------------------
看这个分页,有注释,看不懂就拿下来改着用
http://www.jb51.net/article/27813.htm
------解决方案--------------------
给个例子,最近也在整这个东西。
- PHP code
public static function getuser(CleanRequest &$clean){ Registry::set('clean',$clean); //print_r(Registry::get('clean'));die(); //print_r(Registry::get()); $user=$clean->get('user'); if($user) $where.=($where?' and':' where').' admin_name like \'%'.$user.'%\''; $db=new MysqlDB(); $sql1="select * from admin"; $result=$db->query($sql1); $count=$db->num_rows($result); $pagesize=5; if($page=$clean->get('page')){ $page = intval($page); } else { $page=1; } $pagecount=ceil($count/$pagesize); $limit=$page-1; //if($where) $sql="select * from admin ".$where." limit ".$limit*$pagesize.",$pagesize"; $r=$db->select($sql); foreach($r as $v){ $html.='<tr> <td>'.$v['admin_id'].'</td> <td>'.$v['admin_name'].'</td> <td>'.$v['admin_pwd'].'</td> <td><a href="javascript:void(0)" class="del">删除</a></td> </tr>'; } /*for($i=1;$i$i"; else $html.=" ".$i;*/ //} if($count>$pagesize){ /*if($page==1){//如果页数只有一页 $html .= '首页|上一页'; }*/ //else{ $html.='<tr><td colspan="5">'; if($page>1){ $html .= '<a href="/?r=User&action=index&page=1">首页</a>|<a href="/?r=User&action=index&page='.(%24page-1).'">上一页</a>|'; } if($page==$pagecount||$pagecount==0){//如果当前页等于总也数 $html .= '下一页|尾页'; } else{ $html .= '<a href="/?r=User&action=index&page='.(%24page+1).'">下一 页</a>|<a href="/?r=User&action=index&page='.%24pagecount.'">尾页</a>'; } } $html.=' 共'.$count.'条记录 每页'.$pagesize.'条 共'.$pagecount.'页</td></tr>'; return $html; } <br><font color="#e78608">------解决方案--------------------</font><br>5楼给的是很清楚的,用的面向对象的方法,我也给你一个我自己用的<br><?php <br />require_once 'db.php';<br>session_start();<br>$pagesize = 5; // 每一页显示多少<br>$page = $_GET["page"];<br><br>if($page == ""){ //如果没有设定页数则默认为1<br> $page=1;<br>}<br>$sql = "select * from st_info order by ID desc limit ".($pagesize*($page-1)).",".$pagesize;<br><br>$query=mysql_query($sql); //显示从多少到多少<br><br><br>$quer2=mysql_query("select * from st_info");<br>$num=mysql_num_rows($quer2); //查找所有的行数<br>$pagecount=ceil($num/$pagesize); //应该显示多少页<br><br><br>if($pagecount == 0){<br> echo "sorry,it's null";<br>}else{<br> if(mysql_num_rows($query)==0){<br> echo "sorry,";<br> }<br><br>}<br><br>?> <br>

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

AI Hentai Generator
Generate AI Hentai for free.

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



Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

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

Watch4pro and gt each have different features and applicable scenarios. If you focus on comprehensive functions, high performance and stylish appearance, and are willing to bear a higher price, then Watch 4 Pro may be more suitable. If you don’t have high functional requirements and pay more attention to battery life and reasonable price, then the GT series may be more suitable. The final choice should be decided based on personal needs, budget and preferences. It is recommended to carefully consider your own needs before purchasing and refer to the reviews and comparisons of various products to make a more informed choice.

How to Optimize iPad Battery Life with iPadOS 17.4 Extending battery life is key to the mobile device experience, and the iPad is a good example. If you feel like your iPad's battery is draining too quickly, don't worry, there are a number of tricks and tweaks in iPadOS 17.4 that can significantly extend the run time of your device. The goal of this in-depth guide is not just to provide information, but to change the way you use your iPad, enhance your overall battery management, and ensure you can rely on your device for longer without having to charge it. By adopting the practices outlined here, you take a step toward more efficient and mindful use of technology that is tailored to your individual needs and usage patterns. Identify major energy consumers

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
