I'm trying to make a drop down box that will list the names in a database I already have. When a name is selected, I'd like to change the variable $name to what was selected. I'm not sure how to do this.
Any ideas?
Forgive the ugly code..
I'd like not to SUBMIT the form right after, as the user will have the option to add a number in a field immediately afterwards.
Basically I'd like a user to be able to select his name from a list and enter a number. I'm not worried about authentication or anything.
Any ideas?
Forgive the ugly code..
<form action="">
<select onchange="">
<option value="">Choose a name</option>
<?php
$username="name";
$password="password";
$database="db_tracker";
mysql_connect(localhost,$username,$password);
$query = "SELECT name FROM members";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$n=mysql_result($result,$i,"name");
echo "<option value=" .$n. ">" .$n. "</option>";
$i++;
}
?>
</select>
</form>
I'd like not to SUBMIT the form right after, as the user will have the option to add a number in a field immediately afterwards.
Basically I'd like a user to be able to select his name from a list and enter a number. I'm not worried about authentication or anything.
Last edited:
