Hi,
I am new to php and mysql and being a novice need a little help. I am trying to do a simple search request to pull information off a Mysql table which I have already created called 'tracks'.
The form for the search page is as follows:
<form action="results.php" method="post">
<td align=left class="WhiteText" colspan="3">
Select an area:
</td>
<td>
<select name="county">
<option value="sussex">sussex
<option value="essex">essex
<option value="leices">leices
</select>
<input type=submit value="Search">
</form>
the code for results.php is as follows:
<?
if (!$county)
{
echo "You hvae not entered a county. Please go back and try again.";
exit;
}
$county1 = addslashes($county1);
@ $db = mysql_connect("co-project.lboro.ac.uk", "***", "");
if(!$db = @mysql_connect("co-project.lboro.ac.uk", "", "***"))
die('<font size=+1>An Error Occured</font><hr>Unable to connect to the database. <BR>Check $dbhost, $dbuser, and $dbpasswd in config.php.');
mysql_select_db("tracks");
$query = "select * from tracks where ".$county.";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo "<p>Number of entries found: ".$num_results."</p>";
for ($i=o; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "<p><b>".($i+1).". name: ";
echo htmlspecialchars( stripslashes($row["name"]));
echo "</b><br>address: ";
echo htmlspecialchars (stripslashes($row["address"]));
echo "<br>county: ";
echo htmlspecialchars (stripslashes($row["county"]));
echo "<br>area: ";
echo htmlspecialchars (stripslashes($row["area"]));
echo "</p>";
}
?>
This script doesn't work, all the relivant and all the row names corespond to those of the database.
Any help in order to make this work, or a better way to do the same thing would be much appreciated.
Many thanks
Joe