怎么实翻页~~~~~~~~~急!!!!!!! select * from userinfo order by ID desc limit 0,10 显示第一页,十条记录。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 分页类class PageBar{ var $total; var $onepage; var $num; var $pagecount; var $total_page; var $offset; var $linkhead; function PageBar($total, $onepage, $form_vars='') { $pagecount = $_GET['pagecount']; $this->total = $total; $this->onepage = $onepage; $this->total_page = ceil($total/$onepage); if (empty($pagecount)) { $this->pagecount = 1; $this->offset = 0; } else { $this->pagecount = $pagecount; $this->offset = ($pagecount-1)*$onepage; } if (!empty($form_vars)) { $vars = explode("|", $form_vars); $chk = $vars[0]; $chk_value = $_POST["$chk"]; if (empty($chk_value)) { $formlink = ""; } else { for ($i=0; $i<sizeof($vars); $i++) { $var = $vars[$i]; $value = $_POST["$var"]; $addchar = $var."=".$value; $formlink = $formlink.$addchar."&"; } } } else { $formlink = ""; } $linkarr = explode("pagecount=", $_SERVER['QUERY_STRING']); $linkft = $linkarr[0]; if (empty($linkft)) { $this->linkhead = $_SERVER['PHP_SELF']."?".$formlink; } else { $linkft = (substr($linkft, -1)=="&")?$linkft:$linkft."&"; $this->linkhead = $_SERVER['PHP_SELF']."?".$linkft.$formlink; } } #End function PageBar(); function offset() { return $this->offset; } #End function offset(); function pre_page($char='') { $linkhead = $this->linkhead; $pagecount = $this->pagecount; if (empty($char)) { $char = "[<]"; } if ($pagecount>1) { $pre_page = $pagecount - 1; return "<a href=\"$linkhead"."pagecount=$pre_page\">$char</a>"; } else { return ''; } } #End function pre_page(); function next_page($char='') { $linkhead = $this->linkhead; $total_page = $this->total_page; $pagecount = $this->pagecount; if (empty($char)) { $char = "[>]"; } if ($pagecount<$total_page) { $next_page = $pagecount + 1; return "<a href=\"$linkhead"."pagecount=$next_page\">$char</a>"; } else { return ''; } } #End function next_page(); function num_bar($num='', $color='', $left='', $right='') { $num = (empty($num))?10:$num; $this->num = $num; $mid = floor($num/2); $last = $num - 1; $pagecount = $this->pagecount; $totalpage = $this->total_page; $linkhead = $this->linkhead; $left = (empty($left))?"[":$left; $right = (empty($right))?"]":$right; $color = (empty($color))?"#ff0000":$color; $minpage = (($pagecount-$mid)<1)?1:($pagecount-$mid); $maxpage = $minpage + $last; if ($maxpage>$totalpage) { $maxpage = $totalpage; $minpage = $maxpage - $last; $minpage = ($minpage<1)?1:$minpage; } for ($i=$minpage; $i<=$maxpage; $i++) { $char = $left.$i.$right; if ($i==$pagecount) { $char = "<font color='$color'>$char</font>"; } $linkchar = "<a href='$linkhead"."pagecount=$i'>".$char."</a>"; $linkbar = $linkbar.$linkchar; } return $linkbar; } #End function num_bar(); function pre_group($char='') { $pagecount = $this->pagecount; $linkhead = $this->linkhead; $num = $this->num; $mid = floor($num/2); $minpage = (($pagecount-$mid)<1)?1:($pagecount-$mid); $char = (empty($char))?"[<<]":$char; $pgpagecount = ($minpage>$num)?$minpage-$mid:1; return "<a href='$linkhead"."pagecount=$pgpagecount'>".$char."</a>"; } #End function pre_group(); function next_group($char='') { $pagecount = $this->pagecount; $linkhead = $this->linkhead; $totalpage = $this->total_page; $num = $this->num; $mid = floor($num/2); $last = $num; $minpage = (($pagecount-$mid)<1)?1:($pagecount-$mid); $maxpage = $minpage + $last; if ($maxpage>$totalpage) { $maxpage = $totalpage; $minpage = $maxpage - $last; $minpage = ($minpage<1)?1:$minpage; } $char = (empty($char))?"[>>]":$char; $ngpagecount = ($totalpage>$maxpage+$last)?$maxpage + $mid:$totalpage; return "<a href='$linkhead"."pagecount=$ngpagecount'>".$char."</a>"; } #End function next_group(); function whole_num_bar($num='', $color='') { $num_bar = $this->num_bar($num, $color); $pre_group = $this->pre_group(); $pre_page = $this->pre_page(); $next_page = $this->next_page(); $next_group = $this->next_group(); return $pre_group.$pre_page.$num_bar.$next_page.$next_group; } #End function whole_bar();}#End class PageBar;/***** //example$total = 1000;$onepage = 20;$pb = new PageBar($total, $onepage);$offset = $pb->offset();$pagebar = $pb->whole_num_bar();echo $offset."<br>".$pagebar;return: 0[<<] [1][2][3][4][5][6][7][8][9][10][>][>>] *****/ 分页类<?php/*** 一个用于Mysql数据库的分页类** @author Avenger <[email protected]>* @version 1.0* @lastupdate 2003-04-08 11:11:33*** 使用实例:* $p = new show_page; //建立新对像* $p->file="ttt.php"; //设置文件名,默认为当前页* $p->pvar="pagecount"; //设置页面传递的参数,默认为p* $p->setvar(array("a" => '1', "b" => '2')); //设置要传递的参数,要注意的是此函数必须要在 set 前使用,否则变量传不过去* $p->set(20,2000,1); //设置相关参数,共三个,分别为'页面大小'、'总记录数'、'当前页(如果为空则自动读取GET变量)'* $p->output(0); //输出,为0时直接输出,否则返回一个字符串* echo $p->limit(); //输出Limit子句。在sql语句中用法为 "SELECT * FROM TABLE LIMIT {$p->limit()}";**/class show_page { /** * 页面输出结果 * * @var string */ var $output; /** * 使用该类的文件,默认为 PHP_SELF * * @var string */ var $file; /** * 页数传递变量,默认为 'p' * * @var string */ var $pvar = "p"; /** * 页面大小 * * @var integer */ var $psize; /** * 当前页面 * * @var ingeger */ var $curr; /** * 要传递的变量数组 * * @var array */ var $varstr; /** * 总页数 * * @var integer */ var $tpage; /** * 分页设置 * * @access public * @param int $pagesize 页面大小 * @param int $total 总记录数 * @param int $current 当前页数,默认会自动读取 * @return void */ function set($pagesize=20,$total,$current=false) { global $HTTP_SERVER_VARS,$HTTP_GET_VARS; $this->tpage = ceil($total/$pagesize); if (!$current) {$current = $HTTP_GET_VARS[$this->pvar];} if ($current>$this->tpage) {$current = $this->tpage;} if ($current<1) {$current = 1;} $this->curr = $current; $this->psize = $pagesize; if (!$this->file) {$this->file = $HTTP_SERVER_VARS['PHP_SELF'];} if ($this->tpage > 1) { if ($current>10) { $this->output.='<a href='.$this->file.'?'.$this->pvar.'='.($current-10).($this->varstr).' title="前十页"><<<</a> '; } if ($current>1) { $this->output.='<a href='.$this->file.'?'.$this->pvar.'='.($current-1).($this->varstr).' title="前一页"><<</a> '; } $start = floor($current/10)*10; $end = $start+9; if ($start<1) {$start=1;} if ($end>$this->tpage) {$end=$this->tpage;} for ($i=$start; $i<=$end; $i++) { if ($current==$i) { $this->output.='<font color="red">'.$i.'</font> '; //输出当前页数 } else { $this->output.='<a href="'.$this->file.'?'.$this->pvar.'='.$i.$this->varstr.'">['.$i.']</a> '; //输出页数 } } if ($current<$this->tpage) { $this->output.='<a href='.$this->file.'?'.$this->pvar.'='.($current+1).($this->varstr).' title="下一页">>></a> '; } if ($this->tpage>10 && ($this->tpage-$current)>=10 ) { $this->output.='<a href='.$this->file.'?'.$this->pvar.'='.($current+10).($this->varstr).' title="下十页">>>></a>'; } } } /** * 要传递的变量设置 * * @access public * @param array $data 要传递的变量,用数组来表示,参见上面的例子 * @return void */ function setvar($data) { foreach ($data as $k=>$v) { $this->varstr.='&'.$k.'='.urlencode($v); } } /** * 分页结果输出 * * @access public * @param bool $return 为真时返回一个字符串,否则直接输出,默认直接输出 * @return string */ function output($return = false) { if ($return) { return $this->output; } else { echo $this->output; } } /** * 生成Limit语句 * * @access public * @return string */ function limit() { return (($this->curr-1)*$this->psize).','.$this->psize; }} //End Class?> 楼主是不是要这种效果呀...http://mfsdev.51.net/examples/ 是的话,留下 E-mail 地址,我可以发给你源代码, 是呀 丁丁 要的就是这种效果 不知道你给的例子是不是倒序排的 给我的个源码看看 谢谢了[email protected] 我也想要一份可以吗?先谢谢[email protected] 丁丁,也给我一份好吗[email protected] [email protected]可以給我一份嗎?謝謝~ 我也要,拜托拜托来一份,一定表示感谢![email protected] 楼上各位所需的源码均已由本人发出如有网友需要,可到以下网址下载:http://mfsdev.51.net/free/php_mysql/source/03102.rar声明:不必谢我,要谢的话,就让我们一起感谢 PHP 开发小组的优秀开发人员吧! 谁有整合phplib和adodb类的分页类,发过来用一下.adodb里面带的分页自己带表格什么的. feel8(准备早起的鸟)能不能举个简单的例子用于mysql的那个谢了 简单的翻页<?php $prev_page=$page-1; $next_page=$page+1; if($page==1) { echo "第一页 上一页"."  "; else { echo "<a href='$PATH_INFO? page=1'>第一页</a>"; echo " "; echo "<a href='$PATH_INFO?page=$prev_page'>上一页</a>"; } echo " "; if($page==$page_count) { echo "下一页 最后一页 "; } else { echo "<a href='PATH_INFO?page=$next_page'> </a>"; echo " "; echo "<a href='PATH_INFO?page=$page_count'> </a>"; } } else echo "<p align='center'> /p>"; ?> 数据库查询问题 求助! 哪位兄弟能不能提供一些经典的源程序啊! <input type="file" ...>的文件名怎么显示不出来? 订单购物代码有问题 php中判断表是否存在 有一段OBJECT的代码.我想放到Form中,不知道要怎么放.. 问一个关于PHP实现文件上传的问题 关于input type=hidden提交的问题 PHP是不是没有JSP好,这里的人好少,PHP写的有名的网站也很少! 关于页面跳转 有PHP运行环境的帮帮忙好吗? 中文转换的问题
{
var $total;
var $onepage;
var $num;
var $pagecount;
var $total_page;
var $offset;
var $linkhead;
function PageBar($total, $onepage, $form_vars='')
{
$pagecount = $_GET['pagecount'];
$this->total = $total;
$this->onepage = $onepage;
$this->total_page = ceil($total/$onepage); if (empty($pagecount))
{
$this->pagecount = 1;
$this->offset = 0;
}
else
{
$this->pagecount = $pagecount;
$this->offset = ($pagecount-1)*$onepage;
}
if (!empty($form_vars))
{
$vars = explode("|", $form_vars);
$chk = $vars[0];
$chk_value = $_POST["$chk"];
if (empty($chk_value))
{
$formlink = "";
}
else
{
for ($i=0; $i<sizeof($vars); $i++)
{
$var = $vars[$i];
$value = $_POST["$var"];
$addchar = $var."=".$value;
$formlink = $formlink.$addchar."&";
}
}
}
else
{
$formlink = "";
} $linkarr = explode("pagecount=", $_SERVER['QUERY_STRING']);
$linkft = $linkarr[0]; if (empty($linkft))
{
$this->linkhead = $_SERVER['PHP_SELF']."?".$formlink;
}
else
{
$linkft = (substr($linkft, -1)=="&")?$linkft:$linkft."&";
$this->linkhead = $_SERVER['PHP_SELF']."?".$linkft.$formlink;
} }
#End function PageBar(); function offset()
{
return $this->offset;
}
#End function offset(); function pre_page($char='')
{
$linkhead = $this->linkhead;
$pagecount = $this->pagecount;
if (empty($char))
{
$char = "[<]";
} if ($pagecount>1)
{
$pre_page = $pagecount - 1;
return "<a href=\"$linkhead"."pagecount=$pre_page\">$char</a>";
}
else
{
return '';
} }
#End function pre_page(); function next_page($char='')
{
$linkhead = $this->linkhead;
$total_page = $this->total_page;
$pagecount = $this->pagecount;
if (empty($char))
{
$char = "[>]";
}
if ($pagecount<$total_page)
{
$next_page = $pagecount + 1;
return "<a href=\"$linkhead"."pagecount=$next_page\">$char</a>";
}
else
{
return '';
}
}
#End function next_page(); function num_bar($num='', $color='', $left='', $right='')
{
$num = (empty($num))?10:$num;
$this->num = $num;
$mid = floor($num/2);
$last = $num - 1;
$pagecount = $this->pagecount;
$totalpage = $this->total_page;
$linkhead = $this->linkhead;
$left = (empty($left))?"[":$left;
$right = (empty($right))?"]":$right;
$color = (empty($color))?"#ff0000":$color;
$minpage = (($pagecount-$mid)<1)?1:($pagecount-$mid);
$maxpage = $minpage + $last;
if ($maxpage>$totalpage)
{
$maxpage = $totalpage;
$minpage = $maxpage - $last;
$minpage = ($minpage<1)?1:$minpage;
} for ($i=$minpage; $i<=$maxpage; $i++)
{
$char = $left.$i.$right;
if ($i==$pagecount)
{
$char = "<font color='$color'>$char</font>";
} $linkchar = "<a href='$linkhead"."pagecount=$i'>".$char."</a>";
$linkbar = $linkbar.$linkchar;
} return $linkbar;
}
#End function num_bar(); function pre_group($char='')
{
$pagecount = $this->pagecount;
$linkhead = $this->linkhead;
$num = $this->num;
$mid = floor($num/2);
$minpage = (($pagecount-$mid)<1)?1:($pagecount-$mid);
$char = (empty($char))?"[<<]":$char;
$pgpagecount = ($minpage>$num)?$minpage-$mid:1;
return "<a href='$linkhead"."pagecount=$pgpagecount'>".$char."</a>";
}
#End function pre_group(); function next_group($char='')
{
$pagecount = $this->pagecount;
$linkhead = $this->linkhead;
$totalpage = $this->total_page;
$num = $this->num;
$mid = floor($num/2);
$last = $num;
$minpage = (($pagecount-$mid)<1)?1:($pagecount-$mid);
$maxpage = $minpage + $last;
if ($maxpage>$totalpage)
{
$maxpage = $totalpage;
$minpage = $maxpage - $last;
$minpage = ($minpage<1)?1:$minpage;
} $char = (empty($char))?"[>>]":$char;
$ngpagecount = ($totalpage>$maxpage+$last)?$maxpage + $mid:$totalpage; return "<a href='$linkhead"."pagecount=$ngpagecount'>".$char."</a>";
}
#End function next_group(); function whole_num_bar($num='', $color='')
{
$num_bar = $this->num_bar($num, $color);
$pre_group = $this->pre_group();
$pre_page = $this->pre_page();
$next_page = $this->next_page();
$next_group = $this->next_group(); return $pre_group.$pre_page.$num_bar.$next_page.$next_group;
}
#End function whole_bar();
}
#End class PageBar;
/*****
//example$total = 1000;
$onepage = 20;$pb = new PageBar($total, $onepage);
$offset = $pb->offset();
$pagebar = $pb->whole_num_bar();echo $offset."<br>".$pagebar;return:
0
[<<] [1][2][3][4][5][6][7][8][9][10][>][>>]
*****/
/**
* 一个用于Mysql数据库的分页类
*
* @author Avenger <[email protected]>
* @version 1.0
* @lastupdate 2003-04-08 11:11:33
*
*
* 使用实例:
* $p = new show_page; //建立新对像
* $p->file="ttt.php"; //设置文件名,默认为当前页
* $p->pvar="pagecount"; //设置页面传递的参数,默认为p
* $p->setvar(array("a" => '1', "b" => '2')); //设置要传递的参数,要注意的是此函数必须要在 set 前使用,否则变量传不过去
* $p->set(20,2000,1); //设置相关参数,共三个,分别为'页面大小'、'总记录数'、'当前页(如果为空则自动读取GET变量)'
* $p->output(0); //输出,为0时直接输出,否则返回一个字符串
* echo $p->limit(); //输出Limit子句。在sql语句中用法为 "SELECT * FROM TABLE LIMIT {$p->limit()}";
*
*/
class show_page { /**
* 页面输出结果
*
* @var string
*/
var $output; /**
* 使用该类的文件,默认为 PHP_SELF
*
* @var string
*/
var $file; /**
* 页数传递变量,默认为 'p'
*
* @var string
*/
var $pvar = "p"; /**
* 页面大小
*
* @var integer
*/
var $psize; /**
* 当前页面
*
* @var ingeger
*/
var $curr; /**
* 要传递的变量数组
*
* @var array
*/
var $varstr; /**
* 总页数
*
* @var integer
*/
var $tpage; /**
* 分页设置
*
* @access public
* @param int $pagesize 页面大小
* @param int $total 总记录数
* @param int $current 当前页数,默认会自动读取
* @return void
*/
function set($pagesize=20,$total,$current=false) {
global $HTTP_SERVER_VARS,$HTTP_GET_VARS; $this->tpage = ceil($total/$pagesize);
if (!$current) {$current = $HTTP_GET_VARS[$this->pvar];}
if ($current>$this->tpage) {$current = $this->tpage;}
if ($current<1) {$current = 1;} $this->curr = $current;
$this->psize = $pagesize; if (!$this->file) {$this->file = $HTTP_SERVER_VARS['PHP_SELF'];} if ($this->tpage > 1) {
if ($current>10) {
$this->output.='<a href='.$this->file.'?'.$this->pvar.'='.($current-10).($this->varstr).' title="前十页"><<<</a> ';
}
if ($current>1) {
$this->output.='<a href='.$this->file.'?'.$this->pvar.'='.($current-1).($this->varstr).' title="前一页"><<</a> ';
} $start = floor($current/10)*10;
$end = $start+9; if ($start<1) {$start=1;}
if ($end>$this->tpage) {$end=$this->tpage;} for ($i=$start; $i<=$end; $i++) {
if ($current==$i) {
$this->output.='<font color="red">'.$i.'</font> '; //输出当前页数
} else {
$this->output.='<a href="'.$this->file.'?'.$this->pvar.'='.$i.$this->varstr.'">['.$i.']</a> '; //输出页数
}
} if ($current<$this->tpage) {
$this->output.='<a href='.$this->file.'?'.$this->pvar.'='.($current+1).($this->varstr).' title="下一页">>></a> ';
}
if ($this->tpage>10 && ($this->tpage-$current)>=10 ) {
$this->output.='<a href='.$this->file.'?'.$this->pvar.'='.($current+10).($this->varstr).' title="下十页">>>></a>';
}
}
} /**
* 要传递的变量设置
*
* @access public
* @param array $data 要传递的变量,用数组来表示,参见上面的例子
* @return void
*/
function setvar($data) {
foreach ($data as $k=>$v) {
$this->varstr.='&'.$k.'='.urlencode($v);
}
} /**
* 分页结果输出
*
* @access public
* @param bool $return 为真时返回一个字符串,否则直接输出,默认直接输出
* @return string
*/
function output($return = false) {
if ($return) {
return $this->output;
} else {
echo $this->output;
}
} /**
* 生成Limit语句
*
* @access public
* @return string
*/
function limit() {
return (($this->curr-1)*$this->psize).','.$this->psize;
}} //End Class
?>
http://mfsdev.51.net/examples/
[email protected]
[email protected]
可以給我一份嗎?
謝謝~
http://mfsdev.51.net/free/php_mysql/source/03102.rar声明:不必谢我,要谢的话,就让我们一起感谢 PHP 开发小组的优秀开发人员吧!
adodb里面带的分页自己带表格什么的.
能不能举个简单的例子
用于mysql的那个
谢了
<?php
$prev_page=$page-1;
$next_page=$page+1;
if($page==1)
{
echo "第一页 上一页"."  ";
else
{
echo "<a href='$PATH_INFO? page=1'>第一页</a>";
echo " ";
echo "<a href='$PATH_INFO?page=$prev_page'>上一页</a>";
}
echo " ";
if($page==$page_count)
{
echo "下一页 最后一页 ";
}
else
{
echo "<a href='PATH_INFO?page=$next_page'> </a>";
echo " ";
echo "<a href='PATH_INFO?page=$page_count'> </a>";
}
}
else echo "<p align='center'> /p>";
?>