G'Day, the following code works as intended but on the first load of the page a syntax error occurs:
(You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where Suburb =' at line 1)
<form action="" method="post" name="Form">
<p>Business Type:
<select name="table" id="table">
<option value="Plumber">Plumber</option>
<option value="Electrician">Electrician</option>
<option value="Painter">Painter</option>
</select>
</p>
<p>Suburb:
<select name="suburb" id="suburb">
<option value="Bucketty">Bucketty</option>
<option value="Kulnura">Kulnura</option>
<option value="Gosford">Gosford</option>
</select>
<br />
<input type="submit" name="submit" value="Submit" />
</p>
</form>
<?php
$table = $_POST['table'];
$suburb = $_POST['suburb'];
$sql = mysql_query("SELECT * FROM {$table} WHERE Suburb='$suburb'");
while ($row = mysql_fetch_array($sql))
{
echo '<br/> Name: '.$row['Name'];
echo '<br/> Suburb: '.$row['Suburb'];
echo '<br/> Listing: '.$row['Listing'];
echo '<br/><br/>';
}
?>
Any suggestions would be welcome.
Agro