source-function-F_show_page_navigator

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
Overview

Classes

Interfaces

Exceptions

Functions

  1: <?php
  2: //============================================================+
  3: // File name   : tce_functions_page.php
  4: // Begin       : 2002-03-21
  5: // Last Update : 2011-02-05
  6: //
  7: // Description : Functions for XHTML pages.
  8: //
  9: // Author: Nicola Asuni
 10: //
 11: // (c) Copyright:
 12: //               Nicola Asuni
 13: //               Tecnick.com LTD
 14: //               www.tecnick.com
 15: //               info@tecnick.com
 16: //
 17: // License:
 18: //    Copyright (C) 2004-2010  Nicola Asuni - Tecnick.com LTD
 19: //    See LICENSE.TXT file for more information.
 20: //============================================================+
 21: 
 22: /**
 23:  * @file
 24:  * Functions for XHTML pages.
 25:  * @package com.tecnick.tcexam.shared
 26:  * @author Nicola Asuni
 27:  * @since 2002-03-21
 28:  */
 29: 
 30: /**
 31:  * Display Pages navigation index.
 32:  * @param $script_name (string) url of the calling page
 33:  * @param $sql (string) sql used to select records
 34:  * @param $firstrow (int) first row number
 35:  * @param $rowsperpage (int) number of max rows per page
 36:  * @param $param_array (string) parameters to pass on url via GET
 37:  * @return mixed the number of pages in case of success, FALSE otherwise
 38:  */
 39: function F_show_page_navigator($script_name, $sql, $firstrow, $rowsperpage, $param_array)
 40: {
 41:     global $l, $db;
 42:     require_once('../config/tce_config.php');
 43:     $max_pages = 4; // max pages to display on page selector
 44:     $indexbar = ''; // string for selection page html code
 45:     $firstrow = intval($firstrow);
 46:     $rowsperpage = intval($rowsperpage);
 47:     if (!$sql or ($rowsperpage < 1)) {
 48:         return false;
 49:     }
 50:     if (!$r = F_db_query($sql, $db)) {
 51:             F_display_db_error();
 52:     }
 53:     // build base url for all links
 54:     $baseaddress = $script_name;
 55:     if (empty($param_array)) {
 56:         $baseaddress .= '?';
 57:     } else {
 58:         $param_array = substr($param_array, 5); // remove first "&amp;"
 59:         $baseaddress .= '?'.$param_array.'&amp;';
 60:     }
 61:     $count_rows = preg_match('/GROUP BY/i', $sql); //check if query contain a "GROUP BY"
 62:     $all_updates = F_db_num_rows($r);
 63:     if (($all_updates == 1) and (!$count_rows)) {
 64:         list($all_updates) = F_db_fetch_array($r);
 65:     }
 66:     if (!$all_updates) { //no records
 67:         F_print_error('MESSAGE', $l['m_search_void']);
 68:     } else {
 69:         if ($all_updates > $rowsperpage) {
 70:             $indexbar .= '<div class="pageselector">'.$l['w_page'].': ';
 71:             $page_range = $max_pages * $rowsperpage;
 72:             if ($firstrow <= $page_range) {
 73:                 $page_range = (2 * $page_range) - $firstrow + $rowsperpage;
 74:             } elseif ($firstrow >= ($all_updates - $page_range)) {
 75:                 $page_range = (2 * $page_range) - ($all_updates - (2 * $rowsperpage) - $firstrow);
 76:             }
 77: 
 78:             if ($firstrow >= $rowsperpage) {
 79:                 $indexbar .= '<a href="'.$baseaddress.'firstrow=0">1</a> | ';
 80:                 $indexbar .= '<a href="'.$baseaddress.'firstrow='.($firstrow - $rowsperpage).'" title="'.$l['w_previous'].'">&lt;</a> | ';
 81:             } else {
 82:                 $indexbar .= '1 | &lt; | ';
 83:             }
 84:             $count = 2;
 85:             $x = 0;
 86:             for ($x = $rowsperpage; $x < ($all_updates - $rowsperpage); $x += $rowsperpage) {
 87:                 if (($x >= ($firstrow - $page_range)) and ($x <= ($firstrow + $page_range))) {
 88:                     if ($x == $firstrow) {
 89:                         $indexbar .= $count.' | ';
 90:                     } else {
 91:                         $indexbar .= '<a href="'.$baseaddress.'firstrow='.$x.'" title="'.$count.'">'.$count.'</a> | ';
 92:                     }
 93:                 }
 94:                 $count++;
 95:             }
 96:             if (($firstrow + $rowsperpage) < $all_updates) {
 97:                 $indexbar .= '<a href="'.$baseaddress.'firstrow='.($firstrow + $rowsperpage).'" title="'.$l['w_next'].'">&gt;</a> | ';
 98:                 $indexbar .= '<a href="'.$baseaddress.'firstrow='.$x.'" title="'.$count.'">'.$count.'</a>';
 99:             } else {
100:                 $indexbar .= '&gt; | '.$count;
101:             }
102:             $indexbar .= '</div>';
103:         }
104:     }
105:     echo $indexbar; // display the page selector
106:     return $all_updates; //return number of records found
107: }
108: 
109: //============================================================+
110: // END OF FILE
111: //============================================================+
112: 
 

© 2004-2018 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy