我需要一些关于分页的帮助,问题是我想在第一次点击按钮时显示我的数据库记录,但每次点击分页链接时都需要点击按钮这是我的代码我知道我犯了一些错误请检查并通过纠正我的错误来帮我一个忙..
if (isset($_POST["search"])){
$result=mysql_query("select count(*) from reg_phone");
$row=mysql_fetch_row($result);
$tr=$row[0];
$rpp=4;
$pn=1;
if(isset($_GET['pn']))
{
$pn=$_GET['pn'];
}
$tp=($tr/$rpp);
if($tr/$rpp>=0)
{
$tp++;
}
$from=(($pn-1)*$rpp)+1;
$to=($pn)*($rpp);
$show = "SELECT * FROM reg_phone where Id between $from and $to";
$rs = mysql_query($show) or die(mysql_error());
#****results in Grid****
echo "<table width='100%' border='1' cellpadding='2' border-color='#000' id='tbl'>";
echo "<tr>";
echo "<td style='background: white;'><b>IMEI #</td>";
echo "<td style='background: white;'><b>Phone #</td>";
echo "<td style='background: white;'><b>From Date</td>";
echo "<td style='background: white;'><b>Status</td>";
echo "</tr>";
$rowID = 1;
while ($row = mysql_fetch_array($rs)) {
echo "<tr>";
echo "<td id='imeinum" . $rowID . "'>$row[imei]</td>";
echo "<td id='phnum" . $rowID . "'>$row[phonenum]</td>";
echo "<td id='datepicker" . $rowID . "'>$row[fdate]</td>";
echo "<td id='rad" . $rowID . "'>$row[status]</td>";
echo "</tr>";
$rowID++;
}
echo "</table>";
echo "<ul id='pages'>";
for($i=1;$i<=$tp;$i++)
{
echo "<li><a href='phonereg.php?pn=$i'>$i</a></li>";
}
echo "</ul>";
#**********************
mysql_free_result($rs);
}