PHP Code:
/*
LEGEND
======
$ipp = items_per_pages
$p = $_GET["page"]
$ni = num_items
$np = num_pages
$npc = num_pagesc
$url = like "index.php?action=main&ses=$ses
Using:
echo Paging("$url", $p, $np, $npc, $ipp, $ls, $ni);
*/
if($p=="" || $p<=0)$p=1; $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM tablename")); $ni = $noi[0]; //changable $ipp= 5; $np = ceil($ni/$ipp); $npc = ceil($ni/$ipp);
if(($p>$np)&&$p!=1)$p= $np; $ls = ($p-1)*$ipp;
$sql = "SELECT * FROM tablename ORDER BY orderid DESC LIMIT $ls, $ipp"; $items = mysql_query($sql);
echo mysql_error();
if(mysql_num_rows($items)>0){
while ($item = mysql_fetch_array($items)){
}
}else{
echo "dataEmpty";
}
echo "";
echo Paging("?action=$action&session=$session", $p, $np, $npc, $ipp, $ls, $ni);
// Recall Jump Page if($np>2){ $rets = "; $rets .= ""; $rets .= ""; $rets .= "Jump
"; $rets .= "";
echo $rets;
}
echo "";
PHP Code:
function Paging($pagename, $p, $np, $npc, $ipp, $ls, $ni){ $nav=' ';
if($p<=3){ $px=1; $np=$p+3;
}
if($p>3){ $px=$p-3; $np=$p+3;
}
if($p>=($npc-3)){ $np=$npc;
}
for($jp=$px; $jp<=$np; $jp++){
if($jp==$p){ $nav .= "[$jp] ";
}else{ $nav .= " [$jp] ";
}
}
if($p>1){ $pp = $p-1; $left = "«Prev ";
}
if($p<$np){ $npg = $p+1; $right = "Next»";
}
if($p>4) { $jp=$p-1; $first="«First";
}else{ $first='';
}
if($p<($npc-3)){ $jp=$p+1; $last="Last»";
}else{ $last='';
}
if($ni>$ipp) { $paging = "Page $p of $npc
"; $paging .= "$left $right
$first $nav $last ";
}
if($ipp>$ni){ $paging .= "Page $np of $np";
}else if($ni==0){ $paging .= "Page 0 of 0";
}
return $paging;
}
here is CSS
HTML Code:.paging{
text-align:center;
}
.disable{
background-color: black;
color:#000;
}
No comments:
Post a Comment