The Form is processed by script.php shown below
Session Variables would work if set somewhere between the form and script.
However ,the script stores the form value's and when another page is selected thru the paging system, the script reloads itself and $area = "" causing the problem.
If the script could retain the orginal form values, problem solved. The only line causing a probelm is "$area = $_POST['area'];" at the top of the script
<?php
// from form
$area = $_POST['area'];
function getPagerData($numHits, $limit, $page)
{
$numHits = (int) $numHits;
$limit = max((int) $limit, 1);
$page = (int) $page;
$numPages = ceil($numHits / $limit);
$page = max($page, 1);
$page = min($page, $numPages);
$offset = ($page - 1) * $limit;
$ret = new stdClass;
$ret->offset = $offset;
$ret->limit = $limit;
$ret->numPages = $numPages;
$ret->page = $page;
return $ret;
}
// get the pager input values
$page = $_GET['page'];
$limit = 2;
include("dbconnection.inc");
$query = "SELECT * FROM location";
if ($area != "all") {
$query .= " where area='$area'";
}
$query .= " ORDER BY area";
$result = mysql_query($query)
or die ("Couldn't execute query.");
$numHits = mysql_num_rows($result);
// work out the pager values
$pager = getPagerData($numHits, $limit, $page);
$offset = $pager->offset;
$limit = $pager->limit;
$page = $pager->page;
$query = "SELECT * FROM location";
if ($area != "all") {
$query .= " where area='$area'";
}
$query .= " ORDER BY area limit $offset, $limit";
$result2 = mysql_query($query)
or die ("Couldn't execute query.");
// database output
while ($row = mysql_fetch_array($result2)) #41
{
extract($row);
}
// output paging system
if ($page == 1) // this is the first page - there is no previous page
echo "Prev";
else // not the first page, link to the previous page
echo "<a href=\"script.php?page=" . ($page - 1) . "\">Prev</a>";
for ($i = 1; $i <= $pager->numPages; $i++) {
echo " | ";
if ($i == $pager->page)
echo "Pg $i";
else
echo "<a href=\"script.php?page=$i\">Pg $i</a>";
}
if ($page == $pager->numPages) // this is the last page - there is no next page
echo " | Next";
else // not the last page, link to the next page
echo " | <a href=\"script.php?page=" . ($page + 1) . "\">Next</a>";
?>