dongmi5015 2014-12-20 11:35
浏览 28

分页没有抓取页面有条件

below is my pagination code to display pagination It working and also display pages properly.

but the problem is when i click on page2 it generates an error.

now i debug the code...and find prob... problem is the query is not getting where condition .......

for ex-- the pagination generates pages like this...

1-2-3-4-Next-Last

When I click on page2 or page3 or lastpage the query generates error like

Undefined index: city Undefined index: state

The query is not fetching where clause.

plz tell how to resolve this error...

<?php           
$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$limit = 2;
$startpoint = ($page * $limit) - $limit;
$statement = "news";
mysql_set_charset('utf8'); 
$cit = $_GET['city'];
$sta = $_GET['state'];
$sql="select id,story,headline,photo from {$statement} where state_id = '$sta' and city_id = '$cit' order by id desc LIMIT {$startpoint} , {$limit}";
$query=mysql_query($sql);
?>

<?php echo $Admin->pagination($statement,$limit,$page); ?>
  • 写回答

2条回答 默认 最新

  • doudao0660 2014-12-20 12:35
    关注

    You need to pass city and state values in the query string, in addition to the page, to make the query work.

    Thus,

    http://localhost/nopagination/?page=-1&city=MyCity+OR+1&state=MyState
    

    exemplary, don't forget to double check all incoming values.

    评论

报告相同问题?

悬赏问题

  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线