运行结果是只显示数据库内容的第一页,单击“下一页”仍然停留在第一页上。<?php
$pages=ceil($count/$list_num);
echo "<table width=780 border=0 cellspacing=0 cellpadding=0 align=center class='text'>
<tbody>
<tr> <td width='159'><font color='#ff0000'>目前共有".$count."条记录</font> </td>
<td width='205'>共".$pages."页</td>";
if($offset){
$preoffset=$offset-$list_num;
print "<td width='132'><a href=\"$PHP_SELF?offset=$preoffset\">上一页</a></td>";}
else {
echo "<td width='132'>上一页</td>";
}
$newoffset=$offset+$list_num;
if(($pages!=0)&&(($newoffset/$list_num)!=$pages))
{
print("<td width='158'><a href=\"$PHP_SELF?offset=$newoffset\">下一页</a></td>");
}
else{ echo "<td width='158'>下一页</td>";}
$pageno=($offset/$list_num)+1;
echo "<td width='112' class=text>第<input class=text type='text' size='4'value=".$pageno." readonly>页</td>
<td width='4'> </td> </tr> </table>";
?>php 翻页PHP翻页
$pages=ceil($count/$list_num);
echo "<table width=780 border=0 cellspacing=0 cellpadding=0 align=center class='text'>
<tbody>
<tr> <td width='159'><font color='#ff0000'>目前共有".$count."条记录</font> </td>
<td width='205'>共".$pages."页</td>";
if($offset){
$preoffset=$offset-$list_num;
print "<td width='132'><a href=\"$PHP_SELF?offset=$preoffset\">上一页</a></td>";}
else {
echo "<td width='132'>上一页</td>";
}
$newoffset=$offset+$list_num;
if(($pages!=0)&&(($newoffset/$list_num)!=$pages))
{
print("<td width='158'><a href=\"$PHP_SELF?offset=$newoffset\">下一页</a></td>");
}
else{ echo "<td width='158'>下一页</td>";}
$pageno=($offset/$list_num)+1;
echo "<td width='112' class=text>第<input class=text type='text' size='4'value=".$pageno." readonly>页</td>
<td width='4'> </td> </tr> </table>";
?>php 翻页PHP翻页
再有就是你用上楼主那天告诉你的那个
abstract($_REQUEST); 这个要加到上面
if ($_GET[offset]) {
$offset = $_GET[offset];
}
$count =100 ;
$list_num =5 ;
$pages=ceil($count/$list_num);
echo "<table width=780 border=0 cellspacing=0 cellpadding=0 align=center class='text'>
<tbody>
<tr> <td width='159'><font color='#ff0000'>目前共有".$count."条记录</font> </td>
<td width='205'>共".$pages."页</td>";
if($offset){
$preoffset=$offset-$list_num;
print "<td width='132'><a href=\"$PHP_SELF?offset=$preoffset\">上一页</a></td>";}
else {
echo "<td width='132'>上一页</td>";
}
$newoffset=$offset+1;//$list_num;
if(($pages!=0)&&(($newoffset/$list_num)!=$pages))
{
print("<td width='158'><a href=\"$PHP_SELF?offset=$newoffset\">下一页</a></td>");
}
else{ echo "<td width='158'>下一页</td>";}
$pageno=$offset;
echo "<td width='112' class=text>第<input class=text type='text' size='4'value=".$pageno." readonly>页</td>
<td width='4'> </td> </tr> </table>";
?><?php?>
不知道是不是误解了LZ的意思
一般都是 select * from `table` order by id desc limit 1 $offset*$count/$list_num ,($offset+1)*$count/$list_num
下面这段代码已经用我自己的数据库测试过,可以运行
<?php
if ($_GET[offset]) {
$offset = $_GET[offset];
}
$count =100 ;
$list_num =5 ;
$pages=ceil($count/$list_num);
echo "<table width=780 border=0 cellspacing=0 cellpadding=0 align=center class='text'>
<tbody>
<tr> <td width='159'><font color='#ff0000'>目前共有".$count."条记录</font> </td>
<td width='205'>共".$pages."页</td>";
if($offset){
$preoffset=$offset-1;
print "<td width='132'><a href=\"$PHP_SELF?offset=$preoffset\">上一页</a></td>";}
else {
echo "<td width='132'>上一页</td>";
}
$newoffset=$offset+1;//$list_num;
if(($pages!=0)&&(($newoffset/$list_num)!=$pages))
{
print("<td width='158'><a href=\"$PHP_SELF?offset=$newoffset\">下一页</a></td>");
}
else{ echo "<td width='158'>下一页</td>";}
$pageno=$offset;
echo "<td width='112' class=text>第<input class=text type='text' size='4'value=".$pageno." readonly>页</td>
<td width='4'> </td> </tr> </table>";
?><?php
include 'mysqlconnect.php';
$limit1 = $offset*$count/$list_num ;
$limit2 = ($offset+1)*$count/$list_num;
$sql = "select * from mealtable order by mealuid desc limit $limit1,$limit2";
$query = mysql_query($sql);
var_dump($query);
while ($a = mysql_fetch_row($query)) {
print_r($a);
}
?>