SELECT record from user selection from dropdown box - noobie
Posted: Sat Mar 07, 2009 3:22 pm
Really struggling on this one:
I populate a dropdown box with a list of first and last names from a database. The user finds his name and selects it, then presses a "submit" button. This part works.
I want to get that record from the database by matching the unique key associated with that record but I am not sure how to get it. Then I display all the fields in a form so he can update his information, which I will write back to the database when he presses a "Update" button.
// Creates the drop down list
$result = mysql_query("SELECT * FROM runners");
echo "<select name='fullname'>";
while($list = mysql_fetch_array($result, MYSQL_ASSOC))
echo "<option value=$runnerid[runnerid]>$list[firstname] $list[lastname]</option>";
echo ' <input type="submit" value="select" name="submit">';
// Get specific record
if (isset ($_GET['select'])) {
$firstname = $_GET['firstname'];
$lastname = $_GET['lastname'];
$query = "SELECT * FROM runners WHERE runnerid='$runnerid'";
$result=mysql_query($query);
Thanks!
I populate a dropdown box with a list of first and last names from a database. The user finds his name and selects it, then presses a "submit" button. This part works.
I want to get that record from the database by matching the unique key associated with that record but I am not sure how to get it. Then I display all the fields in a form so he can update his information, which I will write back to the database when he presses a "Update" button.
// Creates the drop down list
$result = mysql_query("SELECT * FROM runners");
echo "<select name='fullname'>";
while($list = mysql_fetch_array($result, MYSQL_ASSOC))
echo "<option value=$runnerid[runnerid]>$list[firstname] $list[lastname]</option>";
echo ' <input type="submit" value="select" name="submit">';
// Get specific record
if (isset ($_GET['select'])) {
$firstname = $_GET['firstname'];
$lastname = $_GET['lastname'];
$query = "SELECT * FROM runners WHERE runnerid='$runnerid'";
$result=mysql_query($query);
Thanks!