时间:2021-07-01 10:21:17 帮助过:93人阅读
/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;
}
}
}
//返回分页条
http://www.bkjia.com/PHPjc/630812.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/630812.htmlTechArticle/mysql教程 分页类(带分页条功能) function fenyezhixin($table,$pagesize=,$paixu=,$do=,$wwhere=){ if(($table == news_fabu) or ($table == product_fabu) or ($table == mes...