$tatol为满足查询条件的总数
$limit为每页输出数
$page_total为总页数
$show为显示数
$limit为每页输出数
$page_total为总页数
$show为显示数
解决方案 »
- PHP写入txt文件,能不能设置字体和颜色??
- 请教关于计划任务执行bat文件的问题,主要用于定时更新服务器的数据库
- 为什么这段代码不能设置cookie!帮帮忙___谢谢大家
- 问一个小菜问题?
- memcache 的限制内存用光了以后,新的项加入会把旧的未过期项删除吗?
- php 淘宝那样的排序怎么做?
- 如何循环输出$_POST[]的值?
- PHP关于POST请求的问题
- 求助:PHP函数嵌套传值的简单问题
- 高分求一个问题--怎么样使得收藏子页面的时,收藏地址却是首页地址?
- 请问:一个http:错误,英雄,帮我!
- 大家好!!我刚开始学php,在网上下载了一个php4.05+apache 1.3.19+zend cache,望大家告诉我如何安装!
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>";
}}