分页没有抓取页面有条件

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); ?>

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.

You have to pass city & state variable with pagination url ,
so wherever you click on page2 or page3 it get this 2 variable that is used in where condition.

Ex.

<a href="yourpage.php?page=2&city=cityname&state=statename">2</a>
<a href="yourpage.php?page=3&city=cityname&state=statename">3</a>
<a href="yourpage.php?page=4&city=cityname&state=statename">4</a>