做了个跳转成功了但跳转的页面分页功能失效了 求大神指点

WBOY
Release: 2016-06-23 13:27:17
Original
1143 people have browsed it

require_once 'conn.php';
$sql="select * from help_relation";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
$pagesize=2;//设定每页的记录数
$pages=ceil($num/$pagesize);//取得总页数
if($pages $page=$_GET[page];//取得传递过来的页数
if($page>$pages){$page=$pages;}//如果传递过来的页数比总页数还大,就让它等于总页数
if($page $kaishi=($page-1)*$pagesize;//为下一步做准备,limit的初始记录
if(isset($_GET['help_keyword_id'])!=''){
    $help_keyword_id=$_GET['help_keyword_id'];
$sql="select * from help_relation where help_keyword_id='$help_keyword_id' order by help_keyword_id desc limit $kaishi,$pagesize";//取得记录从计算出的初始值开始,一共$pagesize条
$result=mysql_query($sql);//取得结果
while($row=mysql_fetch_array($result))
{
echo "

\n"; 
//echo "".$row['id']."\n";
echo "".$row['help_topic_id']."";
echo"\n"; 
}
}
这是代码


回复讨论(解决方案)

没有传递 page 和 help_keyword_id 的代码
$help_keyword_id 只在有传入的 help_keyword_id 时存在,那没传入时不报错吗?

那应该怎么改呢 要重新写一条sql语句吗 还是在原有的基础上改

跪求大神啊 急用 实在是改不来 网上也找不到有用的

你这在网上档的么?你只做了分页,没做显示页码~当然没法做?
你要做一个显示页码的方法吧

点第一页的时候,就是你当前网址?page=1
你现在$page不存在肯定有问题啊?你起码要判断page为空的时候也要显示第一页

另一个$help_keyword_id 也是一样啊,你通过$_GET来获取,你的链接里必须存在啊

例如:www.baidu.com?page=1&help_keyword_id=15
这样才能获取啊

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!