drop box selection from db
Posted: Mon Jun 08, 2009 2:32 pm
I am trying to make a drop box list the choices i have in a table which is "Active" and "Suspended" which is in the acc_status table now in the Users table i have a field "status" which is where the choice is save but i have been unable to get it to list and update the users table.
this is what i have
the edit['id'] is selecting from the users but dont think i am selecting right
Any help you can give me would be helpful
Thanks
this is what i have
Code: Select all
<select name="acctstatus" id="acctstatus">
<?php
$res = mysql_query("SELECT * FROM acc_status") or die("<option>Unable to get departments!</option>");
while($acc = mysql_fetch_array($res, MYSQL_ASSOC)) { ?>
<option value="<?php echo $acc['id']; ?>" <?php if(intval($edit['id']) == intval($acc['id'])) { echo 'selected="selected"'; } ?>><?php echo $acc['level']; ?></option>
<?php } ?>
</select>
the edit['id'] is selecting from the users but dont think i am selecting right
Code: Select all
$r = mysql_query("SELECT * FROM Users WHERE status=$acc['leve'] LIMIT 1 ") or die(mysql_error());
$edit = mysql_fetch_array($r, MYSQL_ASSOC);
@mysql_free_result($r);
Any help you can give me would be helpful
Thanks