php pdo分页
<table width="95%" border="1" cellspacing="0" cellpadding="0" align="center">
<tr align="center" height="30px">
<td>文章标题</td>
<td>文章内容</td>
<td>编辑</td>
</tr>
<?php try{
header("content:text/html; charset:utf-8");
include "conn/conn.php"; if(@$_GET['page']!=""){
$page=$_GET['page'];
}else{
$page=1;
}
if($page){
$page_size=5;
$query="select count(*) as total from tb_affiche"; $result_acticle=$pdo->prepare($query);
$result_acticle->execute();
$msg_count =$result_acticle->rowCount($result_acticle,0,"total");
$page_count=ceil($msg_count/$page_size);
$offset=($page-1)*$page_size;
$sql="SELECT * FROM tb_article order by now desc limit $offset,$page_size ";
if(@$_POST['btnSea']=="查询"){
$txtb= $_POST['txtbook'];
$sql = "SELECT * FROM tb_article where title like '%".trim($txtb)."%' or content like '%".trim($txtb)."%' order by now desc limit 5"; }
$result_acticle=$pdo->prepare($sql);
$result_acticle->execute(); while($res_article=$result_acticle->fetch(PDO::FETCH_ASSOC)){
?>
<tr height="30px">
<td align="center"><?php echo $res_article['title']; ?></td>
<td> <?php echo $res_article['content']; ?></td>
<td width="50px" align="center"><a href="modify.php?id='<?php echo $res_article['id']; ?>'">编辑</a></td>
<td width="50px" align="center"><a href="delete.php?id='<?php echo $res_article['id']; ?>'">删除</a></td>
</tr> <?php
}
} }catch(Exception $ex){
echo $ex->getMessage();
}
?>
</table>
<table align="center" width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>页次:<?php echo $page?>/<?php echo $page_count?>页 记录:<?php echo $msg_count?>条</td>
<td> </td> <td width="40px"><a href="edit.php?page=1">首页</a></td>
<td width="45px"><a href="edit.php?page=<?php
if($page==1){
echo "1";
}else{
echo $page-1;
}
?>">上一页</a></td> <td width="45px"><a href="edit.php?page=<?php
if($page==$page_count){
echo $page_count;
}else{
echo $page+1;
}
?>">下一页</a></td>
<td width="40px"><a href="edit.php?page=<?php echo $page_count?>">尾页</a></td>
</tr>
</table>
php pdo分页的更多相关文章
- PDO原生分页
** PDO分页** 1.PDO连接数据库 $dbh=new PDO('mysql:host=127.0.0.1;dbname=03a','root','root');//使用pdo 2.接收页码 $ ...
- php大力力 [050节] 兄弟连高洛峰 PHP教程 2014年[数据库、PDO教程]
php大力力 [050节] 兄弟连高洛峰 PHP教程 2014年[数据库.PDO教程] 第14章 数据库252.[2014]兄弟连高洛峰 PHP教程14.1.1 复习数据库[已发布,点击下载]253. ...
- php中关于 left join 的分页显示
/* * 统计商机搜索总条数信息 * ftt * 2015-11-10 10:13:15 */ public function getBusinessCount($btype='',$buname=' ...
- php大力力 [019节]php分页类的学习
2015-08-26 php大力力019.php分页类的学习 [2014]兄弟连高洛峰 PHP教程14.2.1 分页需求分析 14:18 [2014]兄弟连高洛峰 PHP教程14.2.2 分页类中分页 ...
- PHP分页初探 一个最简单的PHP分页代码实现
PHP分页代码在各种程序开发中都是必须要用到的,在网站开发中更是必选的一项. 要想写出分页代码,首先你要理解SQL查询语句:select * from goods limit 2,7.PHP分页代码核 ...
- uinty3d使用ugui封装一个分页控件
我们在显示数据时有的数据比较多,手机内存有限,我们不可能分配很多的控件来显示这些数据,分页是一个不错的选择.比如玩家交易行.我们现在封装一个自己简单的分页控件来显示玩家交易行. 分页控件的原理其实很简 ...
- PHP学习笔记之PDO
1. 何为PDO? PDO(PHP数据对象) 是一个轻量级的.具有兼容接口的PHP数据连接拓展,是一个PHP官方的PECL库,随PHP 5.1发布,需要PHP 5的面向对象支持,因而在更早的版本上无法 ...
- PHP分页初探 一个最简单的PHP分页代码的简单实现
PHP分页代码在各种程序开发中都是必须要用到的,在网站开发中更是必选的一项. 要想写出分页代码,首先你要理解SQL查询语句:select * from goods limit 2,7.PHP分页代码核 ...
- redis实现分页
redis实现分页功能,主要是将数据缓存起来,无需频繁查询数据库,减少数据库的压力. 适用场景:单用户操作列表界面分页,如博客列表. 缺点:不可模糊查询,缺少灵活性. 封装类: class XgRed ...
随机推荐
- c++ const总结
[本文链接] http://www.cnblogs.com/hellogiser/p/cplusplus-const-summay.html 看到const 关键字,C++程序员首先想到的可能是con ...
- Android 阅读Tasks and Back Stack文章后的重点摘抄
这篇文章是做android的必读篇目,要仔细阅读,原文连接http://developer.android.com/guide/components/tasks-and-back-stack.html ...
- Java for LeetCode 079 Word Search
Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from l ...
- Java for LeetCode 025 Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If ...
- iOS国际化(Xcode5)
如何将你的app内的语言可以根据系统语言切换而切换呢?这是本篇所要解决的问题.废话先不说,上软硬件环境: 硬件:Macbook Pro 软件:Xcode 5.1 代码:https://github.c ...
- 解决Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.0
jdk问题 解决方案: 更换IDE的jdk
- windows8输入法终极完美修复
现在WIN8正式版出现以来,win8的用户越来越多,毕竟是新系统,BUG肯定是有的,现在小编就为大家解决一个大BUG. 输入法BUG: 现象:1.删除系统输入法,重启后无法调出输入法; 2.卸载用户安 ...
- win7下IIS安装与配置运行网站
1.打开控制面板,点击程序和功能: 2.点击打开或关闭Windows功能进行安装: 3.等待进入安装界面,需要几十秒左右: 4.找到Internet信息服务,将Web管理工具和万维网服务所有勾上,然后 ...
- Mac OS X 上的安装nsq并使用
安装: brew install nsq 使用: The following steps will run a small NSQ cluster on your local machine and ...
- web页面自适应手机屏幕宽度
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scal ...