<?php
$_PHP_SELF = "tut.php";
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'sql';
$rec_limit = 2;
//$cat =$_POST['Mobiles'];
if(isset($_GET['category']) && $_GET['category']) {
$cat= $_REQUEST['category'];
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('enquirytm');
/* Get total number of records */
$sql = "SELECT count(id) FROM postad where scategory = '" . mysql_real_escape_string($_GET['category']) . "' ";
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Error: ' . mysql_error());
}
$row = mysql_fetch_array($retval, MYSQL_NUM );
$rec_count = $row[0];
if( isset($_GET['page'] ) )
{
$page = $_GET['page'] + 1;
$offset = $rec_limit * $page ;
}
else
{
$page = 0;
$offset = 0;
}
$left_rec = $rec_count - ($page * $rec_limit);
$sql = "SELECT * ".
"FROM postad where scategory = '" . mysql_real_escape_string($_GET['category']) . "' ".
"LIMIT $offset, $rec_limit";
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
echo "Title :{$row['id']} <br> ".
"--------------------------------<br>";
}
if( $page > 0 )
{
$last = $page - 2;
echo "<a href=\"$_PHP_SELF?category='$cat' & page=$last\">Last 10 Records</a> |";
echo "<a href=\"$_PHP_SELF?category='$cat' & page=$page\">Next 10 Records</a>";
}
else if( $page == 0 )
{
echo "<a href=\"$_PHP_SELF?category='$cat' & page=$page\">Next 10 Records</a>";
}
else if( $left_rec < $rec_limit )
{
$last = $page - 2;
echo "<a href=\"$_PHP_SELF?category='$cat' & page=$page\">Last 10 Records</a>";
}
mysql_close($conn);
}
?>
我尝试了很多方法但是所有的事情都浪费我的时间.. 有人可以帮助解决这个问题.. 实际上我的问题是然后我点击下一页什么都没发生.. 请帮我.. 提前谢谢..