I've managed to create and populate a drop down list from a mysql query, but I'm not sure how to keep the selected option when the user submits (to edit or add new entry). I'm fairly new to php and mysql, so any help would be greatly appreciated. code to follow, any questions i'll do my best to answer.
<?php
if ($HTTP_POST_VARS['submit'] == 'Edit Staff Info'){
?>
<form action="admin.php" method="post">
<?php
$link = mysql_connect("mysite", "myuser","mypassword") or die ("Could not connect " . mysql_error());
mysql_select_db("db") or die("could not select database");
$query = "select first, last,loc,phone,cell, email from staff where concat(first,' ',last) like '%$lststaff%'"; <----TO COMPARE
$result= mysql_query($query);
list($firstn,$lastn,$locatn,$phonen,$celln,$emailn)=mysql_fetch_row($result);
echo $firstn;
?>
<META HTTP-EQUIV="Refresh" Content="1; URL=http://changeadmin.php">
<?php }elseif ($HTTP_POST_VARS['submit']=='Add New Staff'){
echo "add new staff";
?>
<?php }else{ ?>
<form action="<?php echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post">
<?php
$link = mysql_connect("mysite", "myuser", "mypassword") or die("Could not connect : " . mysql_error());
mysql_select_db("db") or die("Could not select database");
$query = "SELECT distinct count(*) FROM staff";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
list($maxrep)=mysql_fetch_row($result);
?>
<select name="changeadmin">
<?php for ($c=1;$c<($maxrep+1);$c++){
$query2 = "select concat(first_name,' ',last_name) from mos_staff where staffno=$c";
$result2 = mysql_query($query2);
list($lststaff)=mysql_fetch_row($result2);
echo "<option value='' name=$c selected='selected'>$lststaff</option>";
}
?>
</select>
<BR><BR><BR>
<input type="hidden" name="action" value="submitted">
<input type="submit" name="submit" value="Edit Staff Info">
<input type="submit" name="submit" value="Add New Staff">
<br>
</form>
<?php } ?>