Hello,
I have a users table in mySql with the usual stuff. I am searching the same table for my select box as I am for my user sessions so the field names all line up.
I want to create a form eliment that selects all the users, reads the current "Uname" from the session, then defaults (selected) the option that matchs the user name.
I want my options to display "$Fname $Lname" and the value to be the same. Also I have server side (PHP) form validation setup for my other input stuff, but I cannot figure out how to make the select menu "sticky" (keep the same value on refresh).
I think that i need to create an array, compare the output to the session info, then create the select box and mark the option selected according to the matching record from the comparison.
Here is my sql search stuff:
<?PHP
$link = mysql_connect("localhost", "root", "apgar") or die("Could not connect");
$sql = 'SELECT * from Users';
$rs = mysql_query($sql);
?>
here is my select box as of right now:
<select name="requested_by">
<?php do { ?>
<option value="<?php echo $row_rs['Fname'];?> <?php echo $row_rs['Lname'];?>">
<?php echo $row_rs['Fname'];?> <?php echo $row_rs['Lname'];?></option>
<?php } while ($row_rs = mysql_fetch_assoc($rs)); ?>
</select>