paging issue "only few line code"

[code]

<?php //my paging code is not working, when i am clicking next page my address shows ?page=2 but page is empty //to show page2 to i have to click button1 again mean on every next click i have to click button1 too //but if i am remving below if(isset($_POST['button1'])) condition my paging works perfectly if(isset($_POST['button1'])){ //why this condition creating problem

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]
Sponsor our Newsletter | Privacy Policy | Terms of Service