Search
= $pages) && $pages != 1) $last = $_GET['page'] + $limit; //If not last results page, last result equals $page plus limit. else $last = $numrows; // If last results page, last result equals total number of results. // ************** end of pager ************************** if($numrows == 0) { echo "No record found

[<< Back to previous page]\n"; } else { $query = "SELECT lotnum, Payee, Street, City, State, Zip, homephone FROM CCADDRESS GROUP BY LOTNUM"; // ************* search *****************/ if( isset($_GET['search']) && !empty($_GET['search'])) { // WHERE found ? if(!stristr($query,"WHERE ")) $query .= " WHERE ("; else $query .= " AND ("; // add field $query .= " Payee LIKE '%".addslashes($_GET['search'])."%' OR"; $query .= " Street LIKE '%".addslashes($_GET['search'])."%' OR"; $query .= " City LIKE '%".addslashes($_GET['search'])."%' OR"; $query .= " State LIKE '%".addslashes($_GET['search'])."%' OR"; $query .= " Zip LIKE '%".addslashes($_GET['search'])."%' OR"; $query .= " homephone LIKE '%".addslashes($_GET['search'])."%' OR"; $query .= " lotnum LIKE '%".addslashes($_GET['search'])."%' OR"; // delete last OR $query = substr($query,0,strlen($query)-3); $query .= ")"; } // ************* end of search *****************/ $query .= " LIMIT ".$_GET['page'].", $limit"; // add query LIMIT $result = mysql_query($query) or die(mysql_error()); $numrows = mysql_num_rows($result); //echo our table echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $i = 0; while ($row = mysql_fetch_assoc($result)) { // alternate color if($i%2 == 0) echo "\n"; else echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $i++; } echo "
".ucfirst("Name")."".ucfirst("Street")."".ucfirst("City")."".ucfirst("State")."".ucfirst("Zip")."".ucfirst("Lot Number")."".ucfirst("Home Phone")."
 ".$row["Payee"]." ".$row["Street"]." ".$row["City"]." ".$row["State"]." ".$row["Zip"]." ".$row["lotnum"]." ".$row["homephone"]."
\n"; mysql_free_result($result); } // ************** bottom pager ************************** echo "
\n"; if (!empty($_GET['page']) && $_GET['page'] > 0) { $back_page = $_GET['page'] - $limit; $url = $_SERVER["PHP_SELF"]."?page=$back_page"; if(!empty($_GET['search']))$url .= "&search=".$_GET['search']; // add search echo "[<< Previous] \n"; } // loop through each page and give link to it. // no page when only one page if($pages > 1) { for ($i=1; $i <= $pages; $i++) { $ppage = $limit*($i - 1); if ($ppage == $_GET['page']) echo("$i \n"); else { $url = $_SERVER["PHP_SELF"]."?page=$ppage"; if(!empty($_GET['search']))$url .= "&search=".$_GET['search']; // add search echo("Page $i \n"); } } } if(((($_GET['page']+$limit) / $limit) < $pages) && $pages != 1) { $next_page = $_GET['page'] + $limit;// If last page don't give next link. $url = $_SERVER["PHP_SELF"]."?page=$next_page"; if(!empty($_GET['search']))$url .= "&search=".$_GET['search'];// add search echo " [Next Page>>]\n"; } echo "
"; // ************** end of bottom pager ************************** mysql_close($link); ?>