Page 2 of 2

Posted: Tue Sep 27, 2005 9:00 pm
by John Cartwright

Code: Select all

<option value="<?php echo $e_dept; ?>" <? echo (isset($_POST['select_dept']) && $_POST['select_dept'] == $row['select_dept'] ? ' selected="selected' : '');?>> <?php echo $e_dept; ?> </option>

Posted: Tue Sep 27, 2005 9:46 pm
by C_Calav
Hi Jcart

it is not working, but if i explain whats happening - you might be able to see whats wrong.

there is a combo box to select the dept (onchange)

this bring up a list of users in that dept - displayed in a list. click on a user and click add (then goes to user_add.php then back)

and when it comes back the users are no longer in the list, because the first option reset itself.

now is your code you gave me not working because i go from one page to another and back again?

and if you could, explain what the code does that is in the select box.

thank you!

my code for that select box looks like this now

Code: Select all

<form name="select_dept" action="/admin/users.php" method="post">
<select name="select_dept" onchange="this.form.submit();">
<option value="0" selected>Select Dept</option>
<option value="<?php echo $e_dept; ?>" <? echo (isset($_POST['select_dept']) && $_POST['select_dept'] == $row['select_dept'] ? ' selected="selected' : '');?>> <?php echo $e_dept; ?> </option>
  <?php
   include("conection.php");

     $query = "select DISTINCT(e_dept) from tbl_emp";
     $result = mysql_query($query);
     $num_results = mysql_num_rows($result);

     for ($i=0; $i <$num_results; $i++)
     {
     $row = mysql_fetch_array($result);
     $e_dept = $row['e_dept'];
?>
<option value="<?php echo $e_dept; ?>"> <?php echo $e_dept; ?> </option>
<?php
}
?>
</select>

<input type="hidden" name="s_id" value="<?php echo "$s_id"; ?>">
</form>