大佬教程收集整理的这篇文章主要介绍了实现PHP搜索加分页,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
分页显示是浏览大量数据的一种方法。对于初学者来说常常对这个问题摸不着头绪,因此特地撰写此文对这个问题进行详细的讲解,力求让看完这篇文章的朋友在看完以后对于分页显示的原理和实现方法有所了解。
所有示例代码均使用php编写。
所谓分页显示,也就是将数据库中的结果集人为的分成一段一段的来显示。
请详细阅读以下代码,自己调试运行一次,最好把它修改一次,加上自己的功能。
//$sql1="select * from news {$where} {$limit}";
$res=mysql_query($sql1);
?>
<form action="searchpage.php" method="get">
标题:<input type="text" name="title" value="<?php echo $_GET['title']?>" size="8">
关键字<input type="text" name="keywords" value="<?php echo $_GET['keywords']?>" size="8">
作者:<input type="text" name="author" value="<?php echo $_GET['author']?>" size="8">
<input type="button" value="查看全部" onclick="window.location='searchpage.php'">
<input type="submit" value="搜索">
<table border="1" width="1000" align="center">
<tr>
<td>编号</td>
<td>标题</td>
<td>关键字</td>
<td>作者</td>
<td>日期</td>
<td>内容</td>
</tr>
<?php while($row= mysql_fetch_assoc($res)){?>
<tr>
<td><?php echo $row['id'] ?></td>
<td><?php echo $row['title'] ?></td>
<td><?php echo $row['keywords'] ?></td>
<td><?php echo $row['author'] ?></td>
<td><?php echo date("Y-m-d H:i:s",$row['addtime']) ?></td>
<td><?php echo $row['content'] ?></td>
</tr>
<?php }?>
<tr>
<td colspan="6">
<?php
echo " 当前{$page}/{$maxpage}页 共{$totalnum}条";
echo " 首页 ";
echo "上一页";
echo "下一页";
echo " 尾页 ";
?>
</td>
</tr>
</table>
希望本文所述对大家PHP程序设计有所帮助。
以上是大佬教程为你收集整理的实现PHP搜索加分页全部内容,希望文章能够帮你解决实现PHP搜索加分页所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。