<?php
function get_option($arr_option, $selected){
$return = '';
foreach ($arr_option as $key => $value) {
$tmp = ($value==$selected)? ' selected' : '';
$return .= "<option value=\"$key\"$tmp>$value</option>";
}
return $return;
}
$db = new Database();
$id = intval($_GET['id']);
$sql = "SELECT * FROM users WHERE user_id = $id LIMIT 1";
$arr_user = $db->get_row($sql);
$arr_type = $db->get_enum_values('users','user_type');
?>
<form method="POST" action="index.php">
<input type="hidden" name="user_id" value="<?php echo $arr_user->user_id?>">
<table border="1" align="center">
<tr><td colspan="2"> </td></tr>
<tr align="left">
<td width="100px">User</td>
<td width="200px"><input type="text" name="username" value="<?php echo $arr_user->username?>"></td>
</tr>
<tr align="left">
<td width="100px">Password</td>
<td width="200px"><input type="text" name="password" value="<?php echo $arr_user->password?>"></td>
</tr>
<tr align="left">
<td width="100px">Type</td>
<td width="200px"><select name="user_type"><?php echo get_option($arr_type, $arr_user->user_type)?></select></td>
</tr>
<tr align="right"><td colspan="2"><input type="submit" value="Save"></td></tr>
</table>
</form>
|