|  | 
  Ivan Gonzalez - 2010-06-28 04:06:29Omar,
 Nice class, been using without any problems, however I need to add a selector for the number of records per page but I am a little confuse of where to put it and what to call afterwards.
 
 Thanks in Advance
 
 
 Ivan
 
  Ivan Gonzalez - 2010-06-28 15:32:46 - In reply to message 1 from Ivan GonzalezHi Omar, I kind of figure how to add the selector, however I am having an strange problem with blank lines (</br>) being added I the top of the output, (one per row) this is what I did. Any help would be appreciated!
 1.- In testpage.php I added right after <div id="wrapper"> and before <div id='search-box' class="search-box"> my selector
 
 testpage.php
 -----------------------------------------------------------------------------------------------------------
 <div id="wrapper">
 Projects per page: <select name="rpp" id="rpp" onchange="paginate();return false">
 <option selected value=8>8</option>
 <option value=12>12</option>
 <option value=16>16</option>
 <option value=32>32</option>
 <option value=64>64</option>
 </select>
   
 <div id='search-box' class="search-box">
 -----------------------------------------------------------------------------------------------------------
 
 2.- In sub-page.php I commented out the hard-coded $recPerPage variable and added the line to get it from the command line
 
 sub-page.php
 -----------------------------------------------------------------------------------------------------------
 //number of records per page
 //$recPerPage = 8;
 $recPerPage = intval($_GET['rpp']);
 -----------------------------------------------------------------------------------------------------------
 
 3.- In paginate.js I added var rpps = document.getElementById('rpp').value; and modified the var params line
 
 paginate.js
 -----------------------------------------------------------------------------------------------------------
 var searchQuery = document.getElementById('search').value;
 // get the existing GET variables
 --->	var rpps = document.getElementById('rpp').value;
 var getVars = '';
 
 // create the params string
 var url = "sub_page.php";
 --->	var params = 'page='+pageNumber+'&search='+searchQuery+'&rpp='+rpps+getVars;
 -----------------------------------------------------------------------------------------------------------
 
 
 4.- To add wild search capabilities I additionally modified paginator.class.php as follows, mentioning just in case
 
 
 -----------------------------------------------------------------------------------------------------------
 /**
 * Add search capability by manipulating the SQL query to handle the like clause
 *
 * @return
 * added $this->searchQuery = "%" . $this->searchQuery . "%"; and remove % from end of searchQuery, 5 instances
 */
 private function addSearch(){
 $this->searchQuery = $this->conn->real_escape_string ( $this->searchQuery );
 ---->		$this->searchQuery = "%" . $this->searchQuery . "%";
 if (is_array ( $this->fields )) {
 $count = count ( $this->fields );
 for($i = 0; $i < $count; $i ++) {
 // its the first field we have to check for WHERE clause
 if ($i == 0) {
 if (stripos ( $this->query, 'WHERE' )) {
 ---->							$this->query .= " AND ({$this->fields[0]} like '$this->searchQuery'";
 } else {
 ---->							$this->query .= " WHERE ({$this->fields[0]} like '$this->searchQuery'";
 }
 }else{
 ---->						$this->query .= " OR {$this->fields[$i]} like '$this->searchQuery'";
 }
 }
 $this->query .= ") ";
 } else {
 // if only single field to search in
 if (stripos ( $this->query, 'where' )) {
 ---->					$this->query .= " AND name like '$this->searchQuery'";
 } else {
 ---->					$this->query .= " WHERE name like '$this->searchQuery'";
 }
 }
 }
 -----------------------------------------------------------------------------------------------------------
  Ivan Gonzalez - 2010-06-28 17:23:24 - In reply to message 1 from Ivan GonzalezNever mind, I did figure it out!
 In any case would be nice if you could review what I did!
 
 Thanks and keep the good work!
  Omar Abdallah - 2010-06-30 13:25:12 - In reply to message 3 from Ivan GonzalezHello, Glad you had figured it out, I'm sorry I had changed my email and forgotten to check it, If you need any further help it don't hesitate to contact me, btw the GET form generated gets all the existing GET variables and adds them as hidden input fields |