print ""; print ""; print "
"; print ""; print " | "; print " |
";
print " Navigation ";
print " | ";
print "";
print " Search Results for $par Parish ";
print " | ";
print "
"; print ""; print ""; print " | "; print "";
print " ";
print " "; print ""; // If $offset is set below zero (invalid) or empty, set to zero if (empty($offset) || $offset < 0) { $offset=0; } // Connect to database $db = mysql_connect("localhost", "47182_us21691b", "lcboard"); mysql_select_db("47182_db21691a"); // Set $limit. $limit = Max number of results per 'page' // Set $totalrows = total number of rows that unlimited query would return // (total number of records to display across all pages) $limit = 10; $numresults = mysql_query("SELECT * FROM ex_cem WHERE parish='$par'", $db); $totalrows = mysql_num_rows($numresults); // Set $begin and $end to record range of the current page $begin =($offset+1); $end = ($begin+($limit-1)); if ($end > $totalrows) { $end = $totalrows; } // Now retrieve records for current page $query = "SELECT name,address,city,state,zip,phone from ex_cem where parish='$par' order by name limit $offset,$limit"; $result = mysql_query($query, $db); print "
"; // Begin Prev/Next Links // use urlencode to allow prev/next buttons to work in Netscape $par_new=urlencode($par); // Don't display PREV link if on first page if ($offset!=0) { $prevoffset=$offset-$limit; echo "PREV $limit \n"; } // Calculate total number of pages in result $pages = intval($totalrows/$limit); // $pages now contains total number of pages needed unless there is a remainder from division if ($totalrows%$limit) { // has remainder so add one page $pages++; } // Now loop through the pages to create numbered links // ex. 1 2 3 4 5 NEXT for ($i=1;$i<=$pages;$i++) { // Check if on current page if (($offset/$limit) == ($i-1)) { // $i is equal to current page, so don't display a link echo "$i "; } else { // $i is NOT the current page, so display a link to page $i $newoffset=$limit*($i-1); echo "$i \n"; } } // Check to see if current page is last page if ($totalrows==0) { print " No records found for $par Parish. "; } elseif (!((($offset/$limit)+1)==$pages) && $pages!=1) { // Not on the last page yet, so display a NEXT Link $newoffset=$offset+$limit; echo "NEXT $limit \n"; } print ""; print " "; print " |
"; print ""; print ""; ?>