<?php include ("./connect.inc.php3"); include("$header"); include ("./theme.inc.php3"); $limit=5 if (!isset($show)) $show=0; { $result1 = mysql_query("select Count(*) as total from $userstable") or die(mysql_error()); $row=mysql_fetch_Array($result1); $total=$row[total]; $page_total=ceil($total/$limit); }if ($show < $total){ $query = "select * from $userstable order by id desc limit $show, $limit"; $result = mysql_query($query); $number = mysql_numrows($result); } $i = 0;if ($number == 0){ print "<center><b>$no_entry</b></center>"; }elseif ($number > 0) { print "<p align=\"center\">会员总数: $total,共 $page_total 页 </p><br><br>"; while ($i < $number){$row = mysql_fetch_array($result); $name = $row[name]; $id = $row[id]; $area = $row[area]; print "<table border=0 cellspacing=0 cellpadding=3 width=\"800\">"; print "<tr><td width=100% align=\"left\">$id</td></tr><br>"; print "<tr><td width=100% align=\"left\">$name</td></tr><br>"; print "<tr><td width=100% align=\"left\">$area</td></tr><br>"; print "</table><hr width=50%>"; print "<br><br>"; $i++; } } include ("./pages.inc.php3"); include("$footer"); ?> 看看有错没有 谢了
最上面的程序是./pages.inc.php3
echo " <a href=\"$PHP_SELF?show=$vor\">下一页</a>,"; 我由这句判断你的$show应该是当前页的页码,如果是这样的话,那么这句$query = "select * from $userstable order by id desc limit $show, $limit"; 似乎应该是:$show_t = $show * $limit $query = "select * from $userstable order by id desc limit $show_t, $limit";
class page //页面属性类,只需要提供offset,当前页,页面总数,就可以进行翻页 { var $sum; var $now_page; var $offset; var $pre_page; var $next_page; var $begin_record; var $page_cnt; var $page_botton; var $id;function page($offset,$topage,$sum) { global $sum,$topage,$offset,$id; $this->sum=$sum; $this->now_page=$topage; $this->next_page=$this->now_page+1; $this->pre_page=$this->now_page-1; $this->offset=$offset; $this->begin_record=$this->now_page*$this->offset-$this->offset; $this->page_cnt=ceil($this->sum/$this->offset);
include ("./connect.inc.php3");
include("$header");
include ("./theme.inc.php3");
$limit=5
if (!isset($show)) $show=0;
{
$result1 = mysql_query("select Count(*) as total from $userstable") or die(mysql_error());
$row=mysql_fetch_Array($result1);
$total=$row[total];
$page_total=ceil($total/$limit);
}if ($show < $total){
$query = "select * from $userstable order by id desc limit $show, $limit";
$result = mysql_query($query);
$number = mysql_numrows($result);
}
$i = 0;if ($number == 0){
print "<center><b>$no_entry</b></center>";
}elseif ($number > 0) {
print "<p align=\"center\">会员总数: $total,共 $page_total 页 </p><br><br>"; while ($i < $number){$row = mysql_fetch_array($result);
$name = $row[name];
$id = $row[id];
$area = $row[area]; print "<table border=0 cellspacing=0 cellpadding=3 width=\"800\">";
print "<tr><td width=100% align=\"left\">$id</td></tr><br>";
print "<tr><td width=100% align=\"left\">$name</td></tr><br>";
print "<tr><td width=100% align=\"left\">$area</td></tr><br>";
print "</table><hr width=50%>";
print "<br><br>";
$i++;
}
}
include ("./pages.inc.php3");
include("$footer");
?>
看看有错没有 谢了
似乎应该是:$show_t = $show * $limit
$query = "select * from $userstable order by id desc limit $show_t, $limit";
//分页控制类
//宇凡 8月15日
?>
<?
class PageControl
{
var $PageAmount; //总页数
var $RecordAmount; //总记录数
var $Page; //当前页码
var $RecordRow_Per_aPage = 10; //每页显示的记录条数,事先预定,不通过程序更改
var $NextPage; //下一页的页码
var $PriorPage; //上一页的页码
var $StartIndex; //相当于每页显示的起始位置的索引
var $UsingIndex; //当前使用的数据的索引
var $arrIDList; //保存ID的数组function pagecontrol($IDList,$PageNow)
{
if (($PageNow == "") || (round($PageNow) == 0))
{
$PageNow=1;
}
$this->arrIDList = $IDList;
$this->Page = $PageNow;
$this->RecordAmount = count($IDList); if ($this->RecordAmount % $this->RecordRow_Per_aPage == 0) {
$this->PageAmount = $this->RecordAmount / $this->RecordRow_Per_aPage;
} else {
$this->PageAmount = round($this->RecordAmount / $this->RecordRow_Per_aPage);
}
$this->StartIndex = ($this->Page - 1) * $this->RecordRow_Per_aPage;
$this->UsingIndex = $this->StartIndex - 1; //这里减一的目的:得到数据的普遍方法是先Next()再Get数据,比如数据集. if ($this->Page != $this->PageAmount) {
$this->NextPage = $this->Page + 1;
} else {
$this->NextPage = $this->PageAmount;
} if ($this->Page != 1) {
$this->PriorPage = $this->Page - 1;
} else {
$this->PriorPage = 1;
}
}function next_record()
{
$result = false;
if (($this->UsingIndex != $this->RecordAmount - 1) && ($this->UsingIndex - $this->StartIndex < 9)) {
$this->UsingIndex += 1;
$result = true;
} else {
$result = false;
}
return $result;
}function get()
{
$result = $this->arrIDList[$this->UsingIndex];
return $result;
}function show_FirstLink()
{
echo " <a href=".$PHP_SELF."?p=1>最前页</a> ";
}function show_PriorLink()
{
echo " <a href=".$PHP_SELF."?p=".$this->PriorPage.">上一页</a> ";
}function show_NextLink()
{
echo " <a href=".$PHP_SELF."?p=".$this->NextPage.">下一页</a> ";
}function show_LastLink()
{
echo " <a href=".$PHP_SELF."?p=".$this->PageAmount.">最后页</a> ";
}function show_JumpForm()
{
echo "<FORM METHOD=POST ACTION=".$PHP_SELF.">直接到<INPUT TYPE=text NAME=p size=2 class=input>页 <INPUT TYPE=submit value=GOGOGO class=bottem></FORM>";
}}
?>
[email protected]
{
var $sum;
var $now_page;
var $offset;
var $pre_page;
var $next_page;
var $begin_record;
var $page_cnt;
var $page_botton;
var $id;function page($offset,$topage,$sum)
{
global $sum,$topage,$offset,$id;
$this->sum=$sum;
$this->now_page=$topage;
$this->next_page=$this->now_page+1;
$this->pre_page=$this->now_page-1;
$this->offset=$offset;
$this->begin_record=$this->now_page*$this->offset-$this->offset;
$this->page_cnt=ceil($this->sum/$this->offset);
if(($this->begin_record+$this->offset)>$this->sum)
{
$this->page_botton=$this->sum;
}
else
{
$this->page_botton=$this->now_page*$this->offset;
}
}function showpage()
{
global $id;
print "共".$this->page_cnt."页 ";
print "第:".$this->now_page."页<br>"; if ($this->now_page!=1)
{
@print("<a href=\"$PHP_SELF?id=$id&topage=$this->pre_page\">上一页 </a> \n");
}
if ($this->page_cnt!=0 && $this->now_page!=$this->page_cnt)
{
@print("<a href=\"$PHP_SELF?id=$id&topage=$this->next_page\">下一页 </a> \n");
}
for ($y=1;$y<=$this->page_cnt;$y++)
{
@print "<a href=\"$PHP_SELF?id=$id&topage=$y\">$y</a> ";
}
print "<br>";
}}