php 分页遇到错误,点下一页显示没有记录
<?phprequire_once('bookmark_fns.php');session_start();$db=mysql_connect("localhost","...
<?php
require_once('bookmark_fns.php');
session_start();
$db = mysql_connect("localhost","root","cuipi");
mysql_select_db("db",$db);
mysql_query("SET NAMES 'gb2312'");
$result = mysql_query("SELECT * FROM personal ", $db);
$p_strURL = "personal_select.php";
$RecordCount = mysql_num_rows($result);
$PageSize = 5;
$PageCount = ceil($RecordCount/$PageSize);
if(!isset($_POST["page"]))
{
$PageIndex = 1;
}
else
{
$PageIndex = $_POST["page"];
}
if(mysql_affected_rows()>0){
do_html_header("查询");
echo(display_personal_select_form($result,$RecordCount,$PageSize,$PageCount,$pageIndex));
echo(writeNavigation($PageSize, $PageIndex, $RecordCount, $p_strURL));
}else{
do_html_header("Prolem");
echo "没有符合查询条件的记录!";
}
}
?>
问题是第一页好着,点击下一页显示"没有符合查询条件的记录!"
结果集一共两页
好像P大小写这个问题!!我改了还是一样!
<?php
function display_personal_select_form($result,$RecordCount,$PageSize,$PageCount,$PageIndex){
echo "<table><tr>";
echo "<th>公司名称</th>";
echo "<th> 联系地址</th></tr>";
$i=0;
mysql_data_seek($result,($PageIndex-1)*$PageSize);
while($rs = mysql_fetch_object($result))
{
$i++;
echo "<tr><td>".$rs->Name."</td>";
echo "<td >".$rs->Adress."</td></tr>";
if($i == $PageSize)
{
break;
}
}
echo "</table>";
}
?> 展开
require_once('bookmark_fns.php');
session_start();
$db = mysql_connect("localhost","root","cuipi");
mysql_select_db("db",$db);
mysql_query("SET NAMES 'gb2312'");
$result = mysql_query("SELECT * FROM personal ", $db);
$p_strURL = "personal_select.php";
$RecordCount = mysql_num_rows($result);
$PageSize = 5;
$PageCount = ceil($RecordCount/$PageSize);
if(!isset($_POST["page"]))
{
$PageIndex = 1;
}
else
{
$PageIndex = $_POST["page"];
}
if(mysql_affected_rows()>0){
do_html_header("查询");
echo(display_personal_select_form($result,$RecordCount,$PageSize,$PageCount,$pageIndex));
echo(writeNavigation($PageSize, $PageIndex, $RecordCount, $p_strURL));
}else{
do_html_header("Prolem");
echo "没有符合查询条件的记录!";
}
}
?>
问题是第一页好着,点击下一页显示"没有符合查询条件的记录!"
结果集一共两页
好像P大小写这个问题!!我改了还是一样!
<?php
function display_personal_select_form($result,$RecordCount,$PageSize,$PageCount,$PageIndex){
echo "<table><tr>";
echo "<th>公司名称</th>";
echo "<th> 联系地址</th></tr>";
$i=0;
mysql_data_seek($result,($PageIndex-1)*$PageSize);
while($rs = mysql_fetch_object($result))
{
$i++;
echo "<tr><td>".$rs->Name."</td>";
echo "<td >".$rs->Adress."</td></tr>";
if($i == $PageSize)
{
break;
}
}
echo "</table>";
}
?> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询