信息页面
<?php
header("content-type:text/html;charset=utf8");$pdo=new PDO("mysql:host=localhost;dbname=exam",'root','root');
$pdo->exec("set names utf8");
//var_dump($arr);
//搜索后分页
$sea=isset($_REQUEST['sea'])?$_REQUEST['sea']:'';
//总条数
$res=count($pdo->query("select * from hao")->fetchAll(PDO::FETCH_ASSOC));
//echo $res;die;
//每页显示的条数
$num=8;
//总共分多少页
$ye=ceil($res/$num);
//echo $ye;die;
//当前页
$page=isset($_GET['page'])?$_GET['page']:1;
//偏移量
$pian=($page-1)*$num;
//上一页
$prev=$page<=1?1:$page-1;
//下一页
$next=$page>=$ye?$ye:$page+1;
$arr=$pdo->query("select * from hao where title like '%$sea%' limit $pian,$num")->fetchAll(PDO::FETCH_ASSOC);
?>
<center>
<form action="" method="post">
<input type="text" name="sea">
<button>搜索</button>
</form>
<table border="1">
<tr>
<td>编号</td>
<td>地址</td>
<td>标题</td>
</tr>
<?php foreach ($arr as $k => $v) { ?>
<tr>
<td><?php echo $v['id'] ?></td>
<td><?php echo $v['li'] ?></td>
<td><?php echo $v['title'] ?></td>
</tr>
<?php } ?>
</table>
<a href="1_<?php echo $sea ?>.html">首页</a>
<a href="<?php echo $prev ?>_<?php echo $sea ?>.html">上一页</a>
<a href="<?php echo $next ?>_<?php echo $sea ?>.html">下一页</a>
<a href="<?php echo $ye ?>_<?php echo $sea ?>.html">末页</a>
</center>
2..htaccess页面的代码实现(根目录创建文件)
#开启重写引擎
RewriteEngine on
#配置重写规则
RewriteRule seven7/Index.html seven7/index.php [L,NC]
RewriteRule test seven7/test.php [L,NC]
#RewriteRule index.html seven7/1412phpB/20160914/index.php [L,NC]
#分页的伪静态配置
RewriteRule (\d+)_(.*)?.html seven7/1412phpB/20160917/index.php?page=$1&sou=$2 [L,NC]
RewriteRule index.html seven7/1412phpB/20160917/index.php [L]
#防盗链
ReWriteCond %{HTTP_REFERER} !^$ [NC]
ReWriteCond %{HTTP_REFERER} !http://www.study.com.* [NC]
#RewriteRule .*\.(jpeg|png|gif)$ -[F]
RewriteRule .*\.(jpeg|png|gif|jpg)$ 110.gif [L]
#容错处理,当访问不存在的页面时友好提示
ReWriteCond %{REQUEST_FILENAME} !-d
ReWriteCond %{REQUEST_FILENAME} !-f
ReWriteRule .* 404.html [L]