php 不能分页,麻烦帮我看下,并且zend里面while ($row = mysql_fetch_array($query)),还提示警告 谢谢了
<?php@mysql_connect("localhost","root","111");@mysql_select_db("test");$query=@mysql_...
<?php
@mysql_connect("localhost","root","111");
@mysql_select_db("test");
$query=@mysql_query("select * from tb_user");
$pagesize=3;
$sum=mysql_num_rows($query);
if ($sum % $pagesize==0)
{
$total=(int)($sum/$pagesize);
}
else
{
$total=(int)($sum/$pagesize)+1;
}
if (isset($_GET['page']))
{
$p=$_GET['page'];
}
else
{
$p=1;
}
$start=$pagesize * ($p-1);
$query=@mysql_query("select * from tb_user limit $start,$pagesize");
echo "<table border=1>";
while ($row = mysql_fetch_array($query))
{
$id=$row['id'];
$name=$row['name'];
$idcard=$row['idcard'];
$address=$row["address"];
echo "<tr>";
echo "<td>$id</td>";
echo "<td>$name</td>";
echo "<td>$idcard</td>";
echo "<td>$address</td>";
echo "</tr>";
}
echo "</table>";
if ($p>1)
{
$prev=$p-1;
echo "<a href='?page=$prev'>上一页</a>";
}
if($p<total)
{
$next=$p+1;
echo "<a href='?page=$next'>下一页</a>";
}
?> 展开
@mysql_connect("localhost","root","111");
@mysql_select_db("test");
$query=@mysql_query("select * from tb_user");
$pagesize=3;
$sum=mysql_num_rows($query);
if ($sum % $pagesize==0)
{
$total=(int)($sum/$pagesize);
}
else
{
$total=(int)($sum/$pagesize)+1;
}
if (isset($_GET['page']))
{
$p=$_GET['page'];
}
else
{
$p=1;
}
$start=$pagesize * ($p-1);
$query=@mysql_query("select * from tb_user limit $start,$pagesize");
echo "<table border=1>";
while ($row = mysql_fetch_array($query))
{
$id=$row['id'];
$name=$row['name'];
$idcard=$row['idcard'];
$address=$row["address"];
echo "<tr>";
echo "<td>$id</td>";
echo "<td>$name</td>";
echo "<td>$idcard</td>";
echo "<td>$address</td>";
echo "</tr>";
}
echo "</table>";
if ($p>1)
{
$prev=$p-1;
echo "<a href='?page=$prev'>上一页</a>";
}
if($p<total)
{
$next=$p+1;
echo "<a href='?page=$next'>下一页</a>";
}
?> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询