Hi all,
In my update form, I want the fields to recall the values that are already stored. This is very simple in a text field, but for my drop down () I'm having trouble with PHP reading the already stored name of user. Here is my query and code:
$sql = "SELECT users.user_id, users.name FROM users";
$result = mysql_query($sql, $connection)
or die ("Couldn't perform query $sql <br />".mysql_error());
$row = mysql_fetch_array($result);?>
<label>Designated Person:</label> <select name="name" id="name">
<option value="<?php echo $row['user_id']?>" SELECTED><?php echo $row['name']?> - Current</option>
<?php
while($row = mysql_fetch_array($result))
{ ?> <option value="<?php echo $row['user_id']; if (isset($_POST['user_id']));?>"><?php echo $row['fullname']?></option>
<?php } ?>
The result of this displays all of the users (as required) and lets me select a user then perform the change successfully...however the 'SELECTED' is always the first one in my database and never the user that was selected when my activity was added :( !!!