php有id变量分页时,点击下一页不显示 50
php对mysql查询结果分页中,通过传递页面id变量进行结果分页,能显示出来页数和结果,但是点击下一页时就什么也不出来了,可能是id变量没传过去,<?php//Page...
php对mysql查询结果分页中,通过传递页面id变量进行结果分页,能显示出来页数和结果,但是点击下一页时就什么也不出来了,可能是id变量没传过去,
<?php
// Page分页函数
$pid = $_GET["id"];
$page = $_GET["page"];
function Page($rows,$page_size){
global $page,$select_from,$select_limit,$pagenav;
$page_count = ceil($rows/$page_size);
if($page <= 1 || $page == '') $page = 1;
if($page >= $page_count) $page = $page_count;
$select_limit = $page_size;
$select_from = ($page - 1) * $page_size.',';
$pre_page = ($page == 1)? 1 : $page - 1;
$next_page= ($page == $page_count)? $page_count : $page + 1 ;
$pagenav .= "第 $page/$page_count 页 共 $rows 条记录 <br> ";
$pagenav .= "<a href='?page=1'>首页</a> ";
$pagenav .= "<a href='?page=$pre_page'>前一页</a> ";
$pagenav .= "<a href='?page=$next_page'>后一页</a> ";
$pagenav .= "<a href='?page=$page_count'>末页</a>";
}
$pid = $_GET["id"];
$rows = mysql_num_rows(mysql_query("select * from dedejy_archives where typeid like $pid order by typeid desc"));
Page($rows,6);
$sql = "select * from dedejy_archives where typeid like $pid order by typeid desc limit $select_from $select_limit";
$rst = mysql_query($sql);
while ($row = mysql_fetch_array($rst)){
echo '<li>
<a href="article.php?id='.$row['id'].'"> '.$row['title'].'</a> </li> ' ;
}
?> 展开
<?php
// Page分页函数
$pid = $_GET["id"];
$page = $_GET["page"];
function Page($rows,$page_size){
global $page,$select_from,$select_limit,$pagenav;
$page_count = ceil($rows/$page_size);
if($page <= 1 || $page == '') $page = 1;
if($page >= $page_count) $page = $page_count;
$select_limit = $page_size;
$select_from = ($page - 1) * $page_size.',';
$pre_page = ($page == 1)? 1 : $page - 1;
$next_page= ($page == $page_count)? $page_count : $page + 1 ;
$pagenav .= "第 $page/$page_count 页 共 $rows 条记录 <br> ";
$pagenav .= "<a href='?page=1'>首页</a> ";
$pagenav .= "<a href='?page=$pre_page'>前一页</a> ";
$pagenav .= "<a href='?page=$next_page'>后一页</a> ";
$pagenav .= "<a href='?page=$page_count'>末页</a>";
}
$pid = $_GET["id"];
$rows = mysql_num_rows(mysql_query("select * from dedejy_archives where typeid like $pid order by typeid desc"));
Page($rows,6);
$sql = "select * from dedejy_archives where typeid like $pid order by typeid desc limit $select_from $select_limit";
$rst = mysql_query($sql);
while ($row = mysql_fetch_array($rst)){
echo '<li>
<a href="article.php?id='.$row['id'].'"> '.$row['title'].'</a> </li> ' ;
}
?> 展开
展开全部
你把下一页连接用字符串拼接,别直接写引号里,识别不了,
$pagenav .= "<a href='?page=".$next_page."'>后一页</a> ";
前一页和末页也一样。
$pagenav .= "<a href='?page=".$next_page."'>后一页</a> ";
前一页和末页也一样。
追问
和这个没关系,主要就是最前面传的$_GET["id"];
参数,只要点击下一页,参数就没了,如果把这个参数设置成固定的值,就可以正常的上一页,下一页
追答
那你把id再传一遍试试
$pagenav .= "<a href='?page=$next_page&id=值'>后一页</a> ";
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询