Hello
I have got a simple search database script which does not work properly.
It consists of 2 pages.
The first page gives you the opportunity to type in a search. This page is html form.
It then sends the information to the second page. Which is php. This page is meant to display the results from the mysql database.
But instead it displays the message:
Notice: Undefined variable: country in c:\inetpub\wwwroot\resultbyname.php on line 11
and then it just displays the entire contents of the database.
Could you please help. I would be very gratefull. Here is the source code for the first page - searchform.htm
<html>
<head>
<title>searchform</title>
</head>
<body>
<form action="resultbyname.php" method="post">
<input name="country" type=text>
<input type=submit value="search">
</form>
</body>
</html>
Here is the source code for the second page - resultbyname.php
<html>
<head>
<title>search</title>
</head>
<body>
<h2>search</h2>
<br>
<?
$db = mysql_connect("localhost");
mysql_select_db("shoreconnect", $db);
$query = "SELECT sctable.country, sctable.price FROM sctable WHERE country LIKE '%".$country."%'";
$result = mysql_query($query);
while ($record = mysql_fetch_assoc($result)) {
while (list($fieldname, $fieldvalue) = each ($record)) {
echo $fieldname.":<b>".$fieldvalue."</b><br>";
}
echo"<br>";
}
?>
<br>
</body>
</html>
Best Wishes
Kjell