bryonythompson
02-09-2012, 01:13 PM
Hello,
I am very new to HTML and PHP but have managed to create a drop down "Surname" box on my website to list all the current surnames in my mySQL database. However, I also want the user to be able to type into the box and for the drop down list to automatically filter depending on the text the user inserts.
I understand that this is not possible in HTML and PHP and requires some JavaScript, however I have never used this before and have no idea where to start.
Any suggestions or help will be much appreciated. Here is my current HTML and PHP code...
$sql="SELECT Surname FROM Patients";
$result=mysql_query($sql);
?>
<form name="form" method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
Surname: <?php echo "<select name=\"surname\">"; echo "<option size =30 ></option>";
while($row = mysql_fetch_array($result))
{
echo "<option value='".$row['Surname']."'>".$row['Surname']."</option>";
}
echo "</select>";
?>
Thank you!
I am very new to HTML and PHP but have managed to create a drop down "Surname" box on my website to list all the current surnames in my mySQL database. However, I also want the user to be able to type into the box and for the drop down list to automatically filter depending on the text the user inserts.
I understand that this is not possible in HTML and PHP and requires some JavaScript, however I have never used this before and have no idea where to start.
Any suggestions or help will be much appreciated. Here is my current HTML and PHP code...
$sql="SELECT Surname FROM Patients";
$result=mysql_query($sql);
?>
<form name="form" method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
Surname: <?php echo "<select name=\"surname\">"; echo "<option size =30 ></option>";
while($row = mysql_fetch_array($result))
{
echo "<option value='".$row['Surname']."'>".$row['Surname']."</option>";
}
echo "</select>";
?>
Thank you!