mysql 分页类
来源:未知
时间:2014-11-27 23:51 作者:xxadmin
阅读:次
[导读] / 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( sele...
-
/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"
|