Im doing a stockist list for a client. They want to be able to type a county in the text field and a list of the results to be diplayed. What I have at the moment is a text field that the user types a county into and the results are displayed, however I dont know how to display more than one result. Say if there are two stockists in Wales I want it to display the two stockists on after the other
Test the script out at
www.rpa-solutions.com/stockist
There are two entries in the database with the county of wales
Here is the script I have so far
<form method="post" action=" <?php echo $PHP_SELF; ?>">
<?php
$db = mysql_connect($host, $user, $pass);
mysql_select_db($database) or die(mysql_error());
$error = "Sorry there is no match for this county";
// echo"search=". $search; // debug!
if (isset($search))
{
$query = "SELECT * FROM stockist WHERE county = '$search'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_row($result) or die(mysql_error());
if ($row[0] > 0)
{
$id = $row[0];
$add1 = $row[1];
$add2 = $row[2];
$town = $row[3];
$county = $row[4];
$postcode = $row[5];
$telephone = $row[6];
}
}
?>
<p>
<br><b>Name:</b> <?php echo "$add1" ?><br>
<b>Address:</b> <?php echo "$add2"?><br>
<b>Town:</b> <?php echo "$town"?><br>
<b>County:</b> <?php echo "$county"?><br>
<b>Postcode:</b> <?php echo "$postcode"?><br>
<b>Telephone:</b> <?php echo "$telephone"?><br>
<br>
<br>Enter county: <input type="text" name="search" <?php echo "value='$search'"?>>
<input type="submit" name="Search" value="Find">
</form>