pagination issue "please help me"

[code]

<?php //my paging code is not working, when i am clicking next page my address bar shows ?page=2 but page is empty //to show page2 to i have to click button1 again mean on every next page i have to click button1 too // i donot want click button 1 again n again to show next pages please check it make it automatic

if(isset($_POST[‘button1’])){

include(‘mysql_connect.php’);

$per_page = 10;
//defining Page variable
if(!isset($_GET[‘page’]))
{
$page = 1;
}
else
{
$page = $_GET[‘page’];
}
//defining start variable
if ($page <= 1)
$start = 0 ;
else
$start = $page * $per_page - $per_page;

$sql = “select * from geotex”;
$num_rows = mysql_num_rows(mysql_query($sql));
$num_pages = ceil ($num_rows / $per_page) ;
$sql .= " LIMIT $start, $per_page ";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
echo $row[‘PJ_number’]. “
”;
}

// creating prev and next button
$prev = $page - 1 ;
$next = $page + 1 ;

if ($prev > 0)
echo “prev”; // i just echo next and prev button
if ($page < ceil($num_rows/$per_page))
echo “next”; // gives ?page=2 but empty and i have to click button1 again to show ?page2

}

?>

[/code]

Maybe there is no page 2 ?
Do you have more than 10 records ?

yes i have 300 plus records when i am pressing button1 again after pressing next button i shows page 2 means i have to click button1 on every next page to run query again , please check it i spend 3 weeks on this issue :frowning: :frowning: :frowning: :frowning: :frowning:

you have [php] if(isset($_POST[‘button1’])){[/php]
wrapped around everything but when you click page 2 this is still set ?

Sponsor our Newsletter | Privacy Policy | Terms of Service