Hi,
I am a beginner in php and mysql. Someone pls be kind to help me the following if possible.
1. I know the host name, database name, table name
2. The table has 3 fields-State, Name, Specialty.
3. I want to have a drop down list name ‘State’. In the State list, all the states will be listed.
4. Once user select ‘NJ’ from the drop list and hit submit, I want it to go to database>table, and pull up all records equal to ‘NJ’.
--------------
I am just playing with the code. Below code I have. I know I am not near to what I want to accomplish.
-----------------------
<?php
mysql_connect($hostname,$username, $password) or die
("<html><script language='JavaScript'>alert('Unable to connect to database! Please try again later.'),history.go(-1)</script></html>");
mysql_select_db($dbname);
$query = "SELECT State, Name, Specialty FROM $usertable";
$result = mysql_query($query);
?>
<!- HTML form opening tags -->
<form action="action" method="post">
<select name="option">
<?php
//for each row we get from mysql, echo a form input
while ($row = mysql_fetch_array($result)) {
echo "<option Name=\"$row[Name]\">$row[Specialty]</option>\n";
}
?>
<!- HTML form closing tags -->
</select>
<input type="submit">
</form>
---------------------
Pls advise.Thx.