Have an account? Sign in
Login  Register  Facebook
pagination not working with where clause
table name - news

I create pagination code

here I am passing city and state from Navigation bar.
And on basis of that i Tried to show Row with pagination pages.

It works but on 2,3,4,5...N pages it shows error.

Simply Pagination Not fetching data with where condition.
plz suggest proper solution.


when page loads it gets url like
http://localhost/bhaskarhindi/city.php?state=19&city=16
and display pagination rows below.


But when i click on page2 it show url like
http://localhost/bhaskarhindi/city.php?page=2
and shows

error
Undefined index: city
Undefined index: state

<?php
require_once('includes/config.php');
$Admin = new admins;
$baseString = "detail.php";
$cit = $_REQUEST['city'];
$sta = $_REQUEST['state'];
?>

<?php
$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$limit = 1;
$startpoint = ($page * $limit) - $limit;
$statement = "news where state_id = '$sta' and city_id = '$cit'";
?>
<?php
mysql_set_charset('utf8');
$sql="select id,story,headline,photo from {$statement} order by id desc LIMIT {$startpoint} , {$limit}";
$query=mysql_query($sql);
?>
Started: December 20, 2014 Latest Activity: December 20, 2014 php pagination mysql
Your Answer

xDo you want to answer this question? Please login or create an account to post your answer