0
页
我使用下面的脚本更改分页,从这里>>http://www.phpjabbers.com/php--mysql-select-data-and-split-on-pages-php25.html20至10条记录每
,试图显示,每页10笔,但有问题的即时改变它的一些原因和无法理解为什么,我所做的只是将20年改为10年,但由于某种原因,它每页显示5条记录(目前数据库中有11条记录)。
<?php
// check the user is part of the admin group
$connection = mysql_connect("localhost","root","");
if (!$connection)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("rcsetch", $connection);
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * 10;
$sql = "SELECT * FROM u5b0y_chronoforms_data_submitusedequipment ORDER BY cf_id ASC LIMIT $start_from, 10";
$rs_result = mysql_query ($sql,$connection);
?>
<table>
<tr><td>Name</td><td>Phone</td></tr>
<?php
while ($row = mysql_fetch_assoc($rs_result)) {
?>
<tr>
<td><? echo $row["manufacturer"]; ?></td>
<td><? echo $row["model"]; ?></td>
</tr>
<?php
};
?>
</table>
<?php
$sql = "SELECT COUNT(cf_id) FROM u5b0y_chronoforms_data_submitusedequipment";
$rs_result = mysql_query($sql,$connection);
$row = mysql_fetch_row($rs_result);
$total_records = $row[0];
$total_pages = ceil($total_records/10);
for ($i=1; $i<=$total_pages; $i++) {
echo "<a href='test.php?page=".$i."'>".$i."</a> ";
};
?>
它在您更改之前有效吗? –
林不知道,因为我只有11条记录,但它看起来像他们都显示 –
啊,这意味着查询工作正常,然后:/这意味着它可能不是与表的结构。 –