Okay, I have two files. One is called memberlist.php and all it has is a search form on it with a few things that allows users to search for. The second one is called search.php.
My problem lies with search.php. When I enter in my criteria on the memberlist.php page and submit it (memberlist.php uses the search.php to process the form) - everything works fine. The proper search results are shown.
But when there are more than the specified amount of results that I've chosen to show on the result page, search.php won't remember the search criteria that the user entered. So if there are two pages of search results, and you click on the link to view the second - the default error "Sorry, there was no records returned for your search. Please try again." comes up because it can't remember the settings. I was just wondering, what would be the best way to fix this? Here's the contents of search.php
//connection stuff here
$charname = strtolower(strip_tags(mysql_escape_string($_POST['charname'])));
$species = strip_tags(mysql_escape_string($_POST['species']));
$gender = strip_tags(mysql_escape_string($_POST['gender']));
$age = strip_tags(mysql_escape_string($_POST['age']));
$order = strip_tags(mysql_escape_string($_POST['order']));
// Build search query
$query = "select T1.*, T2.speciesname,T2.speciesID FROM
ibf_character_registry T1,
ibf_character_species T2
where T1.firstname LIKE '$charname% and T1.speciesID='$species' T1.speciesID=T2.speciesID order by T1.date $order ";
$result = mysql_query($query);
// dynamic navigation variables
$screen = $_GET['screen'];
$PHP_SELF = $_SERVER['PHP_SELF'];
$rows_per_page=10;
$total_records=mysql_num_rows($result);
$pages = ceil($total_records / $rows_per_page);
if (!isset($screen))
$screen=0;
$start = $screen * $rows_per_page;
$query .= "LIMIT $start, $rows_per_page";
$result= mysql_query($query) or die
("Could not execute query : $query." . mysql_error());
if (mysql_num_rows($result) == 0)
{
echo '<p>Sorry, there was no records returned for your search. Please try again.</p>';
}
else
{
echo '<p><strong>Results:</strong> '.$total_records.' records found.</p>';
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<p>Name : <a href=\"http://www.ramath-lehi.com/persona.php?id=$charID\" target=\"_blank\">$firstname $lastname</a><br />
Gender : $gender<br />
Age : $age<br />";
$i++;
}
echo "<center>";
// create the dynamic links
if ($screen > 0) {
$j = $screen - 1;
$url = "search.php?screen=$j";
echo "<a href=\"$url\">«;</a>";
}
// page numbering links now
$p = 5; // number of links to display per page
$lower = $p; // set the lower limit to $p
$upper = $screen+$p; // set the upper limit to current page + number of links per page
while($upper>$pages){
$p = $p-1;
$upper = $screen+$p;
}
if($p<$lower){
$y = $lower-$p;
$to = $screen-$y;
while($to<0){
$to++;
}
}
if(!empty($to))
{
for ($i=$to;$i<$screen;$i++){
$url = "search.php?screen=" . $i;
$j = $i + 1;
echo " | <a href=\"$url\">$j</a> | ";
}
}
for ($i=$screen;$i<$upper;$i++) {
$url = "search.php?screen=" . $i;
$j = $i + 1;
echo " | <a href=\"$url\">$j</a> ";
}
if ($screen < $pages-1) {
$j = $screen + 1;
$url = "search.php?screen=$j";
echo "<a href=\"$url\">» </a>";
}
echo "</center>";
}