在分页中自动增加打印数据

时间:2014-07-14 10:04:55

标签: php mysql

我知道这是一个愚蠢的问题,但这对我来说是个问题.... 我想用自动增量从mysql打印数据,但是当我使用下面的代码时,它会自动增加同一页面中的值,但我希望它继续到下一页,这里是我的代码

<?php
$perpage = 10; 
$start = (isset($_GET['id'])) ? $_GET['id'] : 0;
$TotalRec = mysql_result(mysql_query("SELECT COUNT(*) FROM register where
r_bid='".$_SESSION["id"]."'"), 0);
$select = "SELECT * FROM register where r_bid='".$_SESSION["id"]."' LIMIT 
$start,$perpage";
$result = mysql_query($select) or die(mysql_error());
$res = mysql_query("select * from regi_balic where b_id='".$_SESSION["id"]."'");
$row1=mysql_fetch_array($res);
$i=1;
while($row = mysql_fetch_array($result))
{   
echo '<tr>
<td align="center" width=5%><font size=3>'.$i.'</font></td>
<td width=12%><font size=3>'.$row1['name'].'</font></td>
<td align="center" width=5%><font size=3><a href="edit_detail.phpid='.$row["r_id"].'
&cand_id='.$_SESSION["id"].'&email='.$row["email"].'">'.$row['name'].'</a></font></td>
<td align="center" width=5%><font size=3>'.$row['reference'].'</font></td>
<td align="right" style="padding-right:8px" width=12%>
<fontsize=3>'.$row['age'].'</font></td>
<td align="right" style="padding-right:8px"  width=12%>
<fontsize=3>'.$row['occupation'].'</font></td>
<td width=12%><font size=3>'.$row['mob_no'].'</font></td>
<td width=2%><a href="process_del_client.php?id='.$row['r_id'].'" 
onClick="returnConfirmSubmit(\'Are You sure ?\')"><img src = "images/delete.png">
</a></td>
</tr>';
}
$i++;
echo '</table>';
if($start == 0)
{
echo "<br>Previous Page&nbsp;";
}
else
{
echo '<br><a href='."./view.php?id=" . ($start - $perpage) . '>'.
"PreviousPage".'</a>&nbsp;';
}
if($start + $perpage >= $TotalRec)
{
echo "&nbsp;Next Page<br>";
}
else
{
echo '&nbsp;<a href='."./view.php?id=" . ($start + $perpage) . '>'."Next Page".'
</a><br>';
}
?>

2 个答案:

答案 0 :(得分:1)

更新会话变量中的值,并将其用于另一个页面进行更新。 实施例..

$ _ SESSION [&#39;值&#39;] = 0 $ _SESSION [&#39;值&#39;] = $ _ SESSION [&#39;值&#39;] ++;

答案 1 :(得分:0)

尝试更改

$i=1;

$i=1+$start;