Hi all,

I have a table with quite a bit of columns in it. Nothing stored there yet, but will be soon. What I need to do is populate a drop down list with the first name and last name of the people in the table and also the unique id of them. That is the first thing. Second thing is I need to then use the selected value to automatically populate a form. Because of the size of the table, the values are going to be inserted into text boxes so no need for the code to build a form for me. I will be giving each text box a unique name so that should make things a bit easier. Third thing is I will then need the admins to be able to change the values that appear in the form now populated and then re-submit those changes to the database. Basically editing an existing record. Sounds quite simple to achieve, but hell am I totally out of my depth with this php stuff! So, any help and I will be able to add to my code base and use it for further projects!

Member Avatar for diafol

OK.
Create a dropdown

get data from mysql resultset:

$drop = '<select name="people">';
while($d = mysql_fetch_assoc($result)){
   $drop .= "\n\t<option value=\"{$d['id']}\">{$d['firstname']} {$d['lastname']}</option>";
}
$drop .= "\n<\select>";
...
echo $drop;

So you should now be able to retrieve the user ID from $_POST['people']

Give that a go and try to retrieve data from the DB based on the ID yourself. See how you get on.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.