<?php class Page { var $total_records=1; ///Total Records returned by sql query var $records_per_page=1; ///how many records would be displayed at a time var $page_name="video/"; ///page name on which the class is called var $start=0; var $page=0; var $total_page=0; var $current_page; var $remain_page; var $show_prev_next=true; var $show_scroll_prev_next=false; var $show_first_last=false; var $show_disabled_links=true; var $scroll_page=0; var $qry_str=""; var $link_para=""; /* returns boolean value if it is last page or not*/ function is_last_page() { return $this->page>=$this->total_page-1?true:false; } /* param : Void returns boolean value if it is first page or not*/ function is_first_page() { return $this->page==0?true:false; } function current_page() { return $this->page+1; } function total_page() { return $this->total_page==0?1:$this->total_page; } //@param : $show = if you want to show desabled links on navigation links. // function show_disabled_links($show=TRUE) { $this->show_disabled_links=$show; } //@param : $link_para = if you want to pass any parameter to link // function set_link_parameter($link_para) { $this->link_para=$link_para; } function set_page_name($page_name) { $this->page_name=$page_name; } //@param : str= query string you want to pass to links. function set_qry_string($str="") { $this->qry_str="&".$str; } function set_scroll_page($scroll_num=0) { if($scroll_num!=0) $this->scroll_page=$scroll_num; else $this->scroll_page=$this->total_records; } function set_total_records($total_records) { if($total_records<0) $total_records=0; $this->total_records=$total_records; } function set_records_per_page($records_per_page) { if($records_per_page<=0) $records_per_page=$this->total_records; $this->records_per_page=$records_per_page; } /* @params * $page_name = Page name on which class is integrated. i.e. $_SERVER['PHP_SELF'] * $total_records=Total records returnd by sql query. * $records_per_page=How many projects would be displayed at a time * $scroll_num= How many pages scrolled if we click on scroll page link. * i.e if we want to scroll 6 pages at a time then pass argument 6. * $show_prev_next= boolean(true/false) to show prev Next Link * $show_scroll_prev_next= boolean(true/false) to show scrolled prev Next Link * $show_first_last= boolean(true/false) to show first last Link to move first and last page. */ function set_page_data($page_name,$total_records,$records_per_page=1,$scroll_num=0,$show_prev_next=true,$show_scroll_prev_next=false,$show_first_last=false) { $this->set_total_records($total_records); $this->set_records_per_page($records_per_page); $this->set_scroll_page($scroll_num); $this->set_page_name($page_name); $this->show_prev_next=$show_prev_next; $this->show_scroll_prev_next=$show_scroll_prev_next; $this->show_first_last=$show_first_last; } /* @params * $user_link= if you want to display your link i.e if you want to user '>>' instead of [first] link then use Page::get_first_page_nav("»") OR for image Page::get_first_page_nav("<img src='' alt='first'>") $link_para: link parameters i.e if you want ot use another parameters such as class. Page::get_first_page_nav("»","class=myStyleSheetClass") */ //Πρώτη σελίδα function get_first_page_nav($user_link="",$link_para="") { if($this->total_page<=1) return; if(trim($user_link)=="") $user_link="[First] "; if(!$this->is_first_page()&& $this->show_first_last) echo ' <a href="'.$this->page_name.'?page=0'.($this->qry_str).'" '.$link_para.' >'.$user_link.'</a> '; elseif($this->show_first_last && $this->show_disabled_links) echo $user_link; } //Τελευταία σελίδα function get_last_page_nav($user_link="",$link_para="") { //qry_str=$qry_str1 if($this->total_page<=1) return; if(trim($user_link)=="") $user_link=" [Last]"; if(!$this->is_last_page()&& $this->show_first_last) echo ' <a href="'.$this->page_name.'?page='.($this->total_page-1).$this->qry_str.'" '.$link_para.' >'.$user_link.'</a> '; elseif($this->show_first_last && $this->show_disabled_links) echo $user_link; } //Επόμενη σελίδα function get_next_page_nav($user_link="",$link_para="") { if($this->total_page<=1) return; if(trim($user_link)=="") $user_link=" Next »"; if(!$this->is_last_page()&& $this->show_prev_next) echo ' <a href="'.$this->page_name.'?page='.($this->page+1).$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> '; elseif($this->show_prev_next && $this->show_disabled_links) echo $user_link; } //Προηγούμενη σελίδα function get_prev_page_nav($user_link="",$link_para="") { if($this->total_page<=1) return; if(trim($user_link)=="") $user_link="« Prev "; if(!$this->is_first_page()&& $this->show_prev_next) echo ' <a href="'.$this->page_name.'?page='.($this->page-1).$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> '; elseif($this->show_prev_next && $this->show_disabled_links) echo $user_link; } function get_scroll_prev_page_nav($user_link="",$link_para="") { if($this->scroll_page>=$this->total_page) return; if(trim($user_link)==" ") $user_link=""; if($this->page>$this->scroll_page &&$this->show_scroll_prev_next) echo ' <a href="'.$this->page_name.'?page='.($this->page-$this->scroll_page).$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> '; elseif($this->show_scroll_prev_next && $this->show_disabled_links) echo $user_link; } function get_scroll_next_page_nav($user_link="",$link_para="") { if($this->scroll_page>=$this->total_page) return; if(trim($user_link)==" ") $user_link=""; if($this->total_page>$this->page+$this->scroll_page &&$this->show_scroll_prev_next) echo ' <a href="'.$this->page_name.'?page='.($this->page+$this->scroll_page).$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> '; elseif($this->show_scroll_prev_next && $this->show_disabled_links) echo $user_link; } function get_number_page_nav($link_para="") { $j=0; $scroll_page=$this->scroll_page; if($this->page>($scroll_page/2)) $j=$this->page-intval($scroll_page/2); if($j+$scroll_page>$this->total_page) $j=$this->total_page-$scroll_page; if($j<0) $i=0; else $i=$j; for(;$i<$j+$scroll_page && $i<$this->total_records;$i++) { if($i==$this->page) echo "<b>".($i+1)."</b>"; else echo ' <span class="border2" style="margin : 0px;padding-top : 1px;padding-left : 4px;padding-right : 4px;padding-bottom : 1px;text-align : center;" ><a href="'.$this->page_name.'?page='.$i.$this->qry_str.$search_result.'" '.$link_para.'>'.($i+1).'</a></span> '; } } function get_page_nav() { if($this->total_records<=0) { //echo "No Records Found"; return false; } $this->calculate(); $this->get_first_page_nav("",$this->link_para); $this->get_scroll_prev_page_nav("",$this->link_para); $this->get_prev_page_nav("",$this->link_para); $this->get_number_page_nav($this->link_para); $this->get_next_page_nav("",$this->link_para); $this->get_scroll_next_page_nav("",$this->link_para); $this->get_last_page_nav("",$this->link_para); return true; } function calculate() { $this->page=$_REQUEST['page']; if(!is_numeric($this->page)) $this->page=0; $this->start=$this->page*$this->records_per_page; $this->total_page=@intval($this->total_records/$this->records_per_page); if($this->total_records%$this->records_per_page!=0) $this->total_page++; } function get_limit_query($qry="") { $this->calculate(); return $qry." LIMIT $this->start,$this->records_per_page"; } }?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Αναζήτηση Δ.Ο.Υ.</title><!-- Meta Tags --><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="Kontos Harry" content="techelp.gr" /><!-- CSS--><link rel="stylesheet" href="css/structure.css" type="text/css" media="screen" /><!-- SCRIPTS --><script language='JavaScript' src='functions.js'></script><script type="text/javascript" src="script.js"></script><body><center><?phpinclude "header.php";include_once("page.inc.php");?><table width="100%" cellpadding="1" cellspacing="1" > <tbody> <tr> <td><h2 id="logo" style="color:#4A5148">Δ.Ο.Υ. - Επεξεργασία</h2></td> </tr> </tbody></table> <br/> <form action="" method="get" id="Form1"> <table width="60%" cellpadding="3" cellspacing="3" style="border-width : 1px 1px 1px 1px;border-style : solid solid solid solid;border-color : #ddebda #ddebda #ddebda #ddebda;" bgcolor="#f1f9ee"> <tbody> <tr> <td align="center" class="text">ΔΟΥ:</td> <td align="center" class="text"><input size="20" type="text" name="doy"></td> <td align="center" class="text">Πόλη:</td> <td align="center" class="text"><input size="20" type="text" name="city"></td> <td align="center" class="text"><input type="submit" value="Αναζήτηση" class="subm"></td> </tr> <?php if(($_GET[doy]) or ($_GET[city])) { $sql = "SELECT bs_doy.*, bs_prefecture.prefecture FROM bs_doy LEFT JOIN bs_prefecture ON bs_doy.prefecture_id = bs_prefecture.prefecture_id WHERE ( doy LIKE '%$_GET[doy]%' and city LIKE '%$_GET[city]%' ) ORDER BY BINARY doy ASC"; $result = mysql_query($sql,$conn); $total_records=@mysql_num_rows($result); $search_string = "&doy=".$_GET[doy]."&city=".$_GET[city]; //echo $search_string; } else { $sql = "SELECT * FROM bs_doy ORDER BY BINARY doy ASC"; $result = mysql_query($sql,$conn); $total_records=@mysql_num_rows($result); } //how many pages in paging menu $scroll=25; $page=new Page(); ///creating new instance of Class Page $page->set_page_data($videosurl,$total_records,$record_per_page,$scroll,true,true,true); $result=@mysql_query($page->get_limit_query($sql)); echo '<p margin : 0px;padding : 0px;padding-bottom : 5px;">'; $page->get_first_page_nav("[Αρχική] "); $page->get_prev_page_nav("«Προηγούμενη "); $page->get_number_page_nav(); $page->get_next_page_nav(" Επόμενη»"); $page->get_last_page_nav(" [Τελευταία]"); echo '</p>'; if(mysql_num_rows($result) > '0') { echo '<table width="100%" cellpadding="3" cellspacing="3"> <tbody> <tr style="background-color : #f2f9ff;"> <td width="10%" align="left" valign="middle" class="text"><b>Τίτλος</b></td> <td width="10%" align="left" valign="middle" class="text"><b>Νομός</b></td> <td width="20%" align="left" valign="middle" class="text"><b>Διεύθυνση</b></td> <td width="10%" align="left" valign="middle" class="text"><b>Πόλη</b></td> <td width="10%" align="left" valign="middle" class="text"><b>Τηλέφωνο</b></td> <td width="20%" align="left" valign="middle" class="text"><b>Υπεύθυνος</b></td> </tr>'; //<td width="25%" align="left" valign="middle" class="text"><b>Διαγραφή</b></td> $n = 1; while($row = mysql_fetch_array($result)) { if(!($n % 2)) { $bg = "class='dif'"; } else { $bg = ''; } $ccode= $row[code]; echo '<tr '.$bg.'> <td width="10%" align="left" valign="top" class="text"> <a href="doy_edit.php?doy_id='.$row[doy_id].'"title="Διόρθωση" >'.$row[doy].'</a> </td> <td width="10%" align="left" valign="top" class="text">'.$row[prefecture].'</td> <td width="20%" align="left" valign="top" class="text">'.$row[address].'</td> <td width="10%" align="left" valign="top" class="text">'.$row[city].'</td> <td width="10%" align="left" valign="top" class="text">'.$row[phone].'</td> <td width="20%" align="left" valign="top" class="text">'.$row[response].'</td> </tr>'; /*<td width="25%" align="left" valign="top" class="text"><span> <a href="doy_delete.php?doy_id='.$row[doy_id].'" style="cursor : pointer;color : white; background-color : #ff0000;border-width : 1px 1px 1px 1px;border-style : solid solid solid solid; border-color : #cc0000 #cc0000 #cc0000 #cc0000;font-weight : bold;width : 120px;height : 20px;" onClick="return confirm(\'Είστε σίγουρος για την διαγραφή? \')">[Χ]Διαγραφή</a></td> */ $n++; } echo '</tbody> </table>'; } else { echo 'Δεν βρέθηκαν καταχωρήσεις.';} ?> <?php echo '<p margin : 0px;padding : 0px;padding-bottom : 5px;">'; $page->get_first_page_nav("[Αρχική] "); $page->get_prev_page_nav("«Προηγούμενη "); $page->get_number_page_nav(); $page->get_next_page_nav(" Επόμενη»"); $page->get_last_page_nav(" [Τελευταία]"); echo '</p>'; ?> </form> </td> </tr> </tbody></table><?phpinclude "footer.php";?></center></body></html>
Code: [Select]... $page->set_page_data($videosurl,$total_records,$record_per_page,$scroll,true,true,true);
... $page->set_page_data($videosurl,$total_records,$record_per_page,$scroll,true,true,true);
$page->set_qry_string("cat=$cat&word=$word&all=$all&order=$order");