I use the following code to pass the name from the drop down menu to the following script. The script displays 10 results with next and previous buttons.
When I replace the variable $search with a proper name for example john the script works fine. But when the name is passed from the drop down menu on the search page it displays 10 and cant find anymore results after this. It seems to forget what the variable $search is after the results have been outputted. I have placed some of the main parts of my script below. The top part of the script that takes the name from the drop dopwn menu and diaplays 10 results and also the bottom half of the script that produces the previous and next buttons.
<?PHP
if(!isset($start)) $start = 0;
$query = "SELECT * FROM names Where firstname='$search' order by rand() LIMIT " . $start . ", 10";
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query($query); //you should do error checking
$num=mysql_numrows($result);
//output from database. Php code goes here to display results. Once 10 results have been outputted do the folllowing//
$query = "SELECT count(*) as count FROM names ";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];
if($start > 0)
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - 10) .
"\">Previous</a><BR>\n";
if($numrows > ($start + 10))
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start + 10) .
"\">Next</a><BR>\n";
?>
Thank you for your help.