I've made a page in which an admin can manage and update account information of other users. I currently have a drop-down list that is able to select which user from the database to update, but I would like it to auto-populate the form below it, based on which option they choose.
How do I go about doing this?
(My SQL table's name is 'user', while the values I'd like to pull are under 'userID', 'firstName', and 'lastName'.)
My form:
<form id="form0" method="post" action="doEditUser.php">
<fieldset id="account">
<legend>Update an Account</legend>
<ul>
<li>
<label for="userID">Select an Account: </label>
<select id="userID" name="userID">
<?php
$result = mysql_query($sql);
if(empty($result)){
$num_results = 0;
}else{
$num_results = mysql_num_rows($result);
}
for($i=0; $i < $num_results; $i++){
$row = mysql_fetch_array($result);
?>
<option><?php echo trim($row["userID"]);?></option>
<?php
}
?>
</select>
</li>
<li>
<label for="firstName">First Name: </label><input type="text" id="firstName" name="firstName" size="20" value=""/>
</li>
<li>
<label for="lastName">Last Name: </label><input type="text" id="lastName" name="lastName" size="20" value=""/>
</li>
<li><input type="submit" name="submit" value="Update Account" /></li>
</ul>
</fieldset>
</form>
How do I go about doing this?
(My SQL table's name is 'user', while the values I'd like to pull are under 'userID', 'firstName', and 'lastName'.)
My form:
<form id="form0" method="post" action="doEditUser.php">
<fieldset id="account">
<legend>Update an Account</legend>
<ul>
<li>
<label for="userID">Select an Account: </label>
<select id="userID" name="userID">
<?php
$result = mysql_query($sql);
if(empty($result)){
$num_results = 0;
}else{
$num_results = mysql_num_rows($result);
}
for($i=0; $i < $num_results; $i++){
$row = mysql_fetch_array($result);
?>
<option><?php echo trim($row["userID"]);?></option>
<?php
}
?>
</select>
</li>
<li>
<label for="firstName">First Name: </label><input type="text" id="firstName" name="firstName" size="20" value=""/>
</li>
<li>
<label for="lastName">Last Name: </label><input type="text" id="lastName" name="lastName" size="20" value=""/>
</li>
<li><input type="submit" name="submit" value="Update Account" /></li>
</ul>
</fieldset>
</form>