other_param=$other_param; $this->max=$max; $this->cur_page=$cpg; $this->npages=$npgs; $this->linkfile=$act; $sq=stripslashes($sq); $this->sql=$sq; $this->next=$nxt; if($this->cur_page==0) $this->cnt_pages(); if($this->npages>1) $this->disp_pageline(); //else print "
"; $this->calc_limit(); $this->sql=urldecode($this->sql); $this->sql=stripslashes($this->sql); $this->sql=ereg_replace("''","'",$this->sql); $this->sql.=" limit $this->cur_limit,$this->max"; } function cnt_pages() { $res=mysql_query($this->sql); $count=mysql_num_rows($res); $this->npages=$count/$this->max; $intdec=explode('.',$this->npages); if($intdec[1]>0) $this->npages=$intdec[0]+1; $this->cur_page=1; } function calc_limit() { $this->cur_limit=($this->cur_page-1)*$this->max; } function disp_pageline() { $lmax=5; $this->sql=stripslashes($this->sql); $this->sql=urlencode($this->sql); $lines=$this->npages/$lmax; $intdec=explode('.',$lines); if($intdec[1]>0) $lines=$intdec[0]+1; $pagenoline=""; $start=$this->next*$lmax+1; $end=($this->next+1)*$lmax; if($end>$this->npages) $end=$this->npages; if($this->next) { $this->prev=$this->next-1; $i=$this->prev*$lmax+1; $pagenoline.=$this->create_link('Prev',$i); $pagenoline.="  "; } for($i=$start;$i<=$end;$i++) { if($i==$this->cur_page) { $pagenoline.="$i"; $pagenoline.="  "; } else { $pagenoline.=$this->create_link($i,$i); $pagenoline.="  "; } } $this->next+=1; if($i<=$this->npages) { $pagenoline.=$this->create_link('Next',$i); } print "
Pages: $pagenoline
"; } function create_link($var1,$var2) { $link="$this->linkfile?"; reset($this->other_param); while(list($key,$val)=each ($this->other_param)) { $link.="$key=".urlencode($val)."&"; } $link.="cur_page=$var2&npages=$this->npages&sql=$this->sql&max=$this->max"; if($var1=='Prev') $link.="&next=$this->prev"; else $link.="&next=$this->next"; $alink="$var1"; return $alink; } } ?>