Please help out as i am a beginner in PHP
I have a table with the name doinfo with the fields doctor,hospital, and city.
What I want is that when I select city from the dropdownlist, it should give me its details i.e the doctor and hospital.
I am able to get the city from the table in the drop down list,but when i select the 1 of the cities i am unable to get their details from the database.
here is the code I have done so far
<?
$query = "SELECT DISTINCT `city` FROM `docinfo`";
$result = mysql_query ($query);
while($nt=mysql_fetch_array($result))
{
echo "<option value=$nt[city]>$nt[city]</option>";
}
echo "</select><input type='submit' name='submit' value='Go'><br>";
$q = "SELECT `doctor`, `hospital` FROM `docinfo` WHERE `city` = '$nt[city]'";
$r = mysql_query($q);
while($row = mysql_fetch_array($r))
{
echo "Doctor:".$row[doctor].", Hospital name:".$row[hospital]."<br/>";
}
?>