mysql 分页类(带分页条功能)
풀어 주다: 2016-06-13 10:07:58
/mysql教程 分页类(带分页条功能)
function fenyezhixin($table,$pagesize="",$paixu="",$do="",$wwhere=""){
if(($table == "news_fabu") or ($table == "product_fabu") or ($table == "message") or ($table == "down_fabu") or ($table == "kucun")){
$query = @mysql_query("select * from $table $wwhere");
$pagesize = $pagesize;
$sum = mysql_num_rows($query);
if($sum == 0){
$pagesize = 1;
}
if($pagesize=="0"){
$sum = "1";
}
if (@($sum % $pagesize) == 0){
$total = @(int)($sum / $pagesize);
}else{
$total = @(int)($sum / $pagesize) + 1;
}
if($total == 0){$total=1;}
if (isset($_get['page'])){
$p = (int)$_get['page'];
}else{
$p = 1;
}
$start = $pagesize * ($p - 1);
$query = @mysql_query("select * from $table $wwhere order by $paixu limit $start,$pagesize") or die ("数据查询失败2!");
if ($do == 1){
$queryarray = array($query,$total,$sum,$p);
return $queryarray;
}
if($do == 2){
$parray = array($total,$sum,$p);
return $parray;
}
}else{
$query = @mysql_query("select * from $table $wwhere order by $paixu limit $pagesize") or die ("数据查询失败1!");
if ($do == 1){
$queryarray = array($query,$total,$sum,$p);
return $queryarray;
}
if($do == 2){
$parray = array($total,$sum,$p);
return $parray;
}
}
}
//返回分页条
function fenyedaohang($total="",$sum="",$p="",$menut=""){
$w = substr($menut,strrpos($menut,"&")+1,2);
$wr = substr($menut,strrpos($menut,"=")+1,strlen($menut));
$pindao = $_server["script_name"];$pinstrlen = strrpos($pindao,"/"); $pindao = substr($pindao,$pinstrlen+1,strlen($pindao));
if($w == "pr"){
$queryr = mysql_query("select feiye.feiye_what from feiye where feiye.feiye_page = '$pindao'");
$rows = mysql_fetch_row($queryr); $rrows = $rows[0];
if(empty($rrows)){
mysql_query("insert into `feiye` (`feiye_page`, `feiye_what`) values ('$pindao', '$wr')");
echo "";
}else{
if($wr != $rrows){
mysql_query("update `feiye` set `feiye_what`='$wr' where (`feiye_page`='$pindao')");
echo "";
}
}
}
if($w == "ne"){
$queryr = mysql_query("select feiye.feiye_what from feiye where feiye.feiye_page = '$pindao'");
$rows = mysql_fetch_row($queryr); $rrows = $rows[0];
if(empty($rrows)){
mysql_query("insert into `feiye` (`feiye_page`, `feiye_what`) values ('$pindao', '$wr')");
echo "";
}else{
if($wr != $rrows){
mysql_query("update `feiye` set `feiye_what`='$wr' where (`feiye_page`='$pindao')");
echo "";
}
}
}
echo "共"."$total"."页 "."记录"."$sum"."条 当前"."$p"."/"."$total"."页 ";
if($total == 1){
echo "首页";
}else{
echo "首页"." ";
}
if ($p > 1){
$prev = $p - 1;
echo "上一页"." ";
}else{
echo "上一页"." ";
}
$page = $_get["page"];
$pagesum = $page+5;
if($total >= 11){
if($pagesum
$pagesum = 11;
}
}
if($pagesum >= $total){
$pagesum = $total;
}
$pagestart = $page - 5;
if($pagestart
$pagestart = 1;
}
if($total >= 11 and ($total-4)
$pagestart = $total-10;
}
for($i=$pagestart;$i
if($i == $p){
echo " $i ";
}else{
echo "$i";
}
}
if ($p
$next = $p + 1;
echo " 下一页"." ";
}else{
echo "下一页"." ";
}
if($total == 1){
echo "尾页";
}else{
echo "尾页";
}
}
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
저자별 최신 기사
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31