- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
function pages($table,$id,$page,$func,$num,$p,$count=false){
global $db,$basepref;
$outpages = array();
if($count==0){
$item_num = $db->fetchrow($db->query("SELECT COUNT(".$id.") AS total FROM ".$basepref."_".$table.""));
} else {
$item_num['total'] = $count;
}
$nums = @ceil($item_num['total']/$num);
if($nums <= 1){
$outpages[]=("<span class=\"pagesempty\">1</span>");
} else {
if($p > 1){
$goback=$p-1;
$outpages[]=("<a class=\"pages\" href=\"".$page.".php?dn=".$func."&p=1\"><<</a>");
$outpages[]=("<a class=\"pages\" href=\"".$page.".php?dn=".$func."&p=$goback\"><</a>");
}
for($i=1; $i<$nums+1; $i++) {
if($i==$p){
$outpages[]=("<span class=\"pagesempty\">$i</span>");
} else {
if(($i > $p) && ($i < $p+5) || ($i < $p) && ($i > $p-5)){ $outpages[]=("<a class=\"pages\" href=\"".$page.".php?dn=".$func."&p=$i\">$i</a>"); }
}
}
if($p<$nums){
$gonext=$p+1;
$outpages[]=("<a class=\"pages\" href=\"".$page.".php?dn=".$func."&p=$gonext\">></a>");
$outpages[]=("<a class=\"pages\" href=\"".$page.".php?dn=".$func."&p=$nums\">>></a>");
}
}
return implode(' ',$outpages);
}
1_and_0 25.12.2010 18:09 # 0