when i am using simple paging scrip with out using Post value and with out IF statement my query works perfectly but when i am adding _post value thorugh a form i have to use IF statement to get values before runing the query , in this case my paging not working properly when i am pressing Next page button it does not shows any record
please check and correct my coding
<html>
<head><title>Supplier</title>
</head>
<body>
<form method= "post" action="help.php">
<input type ="hidden" name ="submitted" value = "true" />
<input type="text" name="criteria" />
<input type="submit" />
</form>
<?php
if (isset($_POST['submitted']))
{
include('mysql_connect.php');
$per_page = 10;
if(!isset($_GET['page']))
{
$page = 1;
}
else
{
$page = $_GET['page'];
}
if ($page <= 1)
$start = 0 ;
else
$start = $page * $per_page - $per_page;
//$value = '90';
//$sql = "select * from geotex where Buyer = $value ";
//if u run this query and removing above if statement my paging works
$criteria = $_POST['criteria'];
$sql = "select * from geotex where Buyer = $criteria ";
$num_rows = mysql_num_rows(mysql_query($sql));
$num_pages = ceil ($num_rows / $per_page) ;
$sql .= " LIMIT $start, $per_page ";
$result = mysql_query($sql);
//to display my result i make a table here
echo "<center>";
echo "<table CELLPADDING=10 border =1>";
echo "<tr> <th>Supplier</th> <th>Buyer</th> <th>PJ_Number</th> <th style='text-align:right'>Quantity</th></tr>";
while ($row = mysql_fetch_array($result))
// my disply re#*$! working perfectly
{
echo "<tr><td>";
echo $row['supplier'];
echo "</td><td>";
echo $row['Buyer'];
echo "</td><td>";
echo $row['PJ_number'];
echo "</td><td style='text-align:right'>";
echo $row['Total_qty'];
echo "</td></tr>";
}
echo "</table>";
$prev = $page - 1 ;
$next = $page + 1 ;
// i just echo next and prev button
echo "<hr>";
if ($prev > 0)
echo "<a href='?page=$prev'>prev</a>";
if ($page < ceil($num_rows/$per_page))
echo "<a href='?page=$next'>next</a>";
// giving page 2 blank in current case
//but with out if statement it works perfectly
}
?>
</body>
</html>