PHP Classes

File: tpl.set_user.php

Recommend this page to a friend!
  Classes of marcelo entraigas   AMD   tpl.set_user.php   Download  
File: tpl.set_user.php
Role: Example script
Content type: text/plain
Description: Example - template form
Class: AMD
Add, modify and delete MySQL table records
Author: By
Last change:
Date: 13 years ago
Size: 1,263 bytes


Class file image Download

function get_option($arr_option, $selected){
$return = '';
        foreach (
$arr_option as $key => $value) {
$tmp = ($value==$selected)? ' selected' : '';
$return .= "<option value=\"$key\"$tmp>$value</option>";
$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">&nbsp;</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 align="left">
        <td width="100px">Password</td>
        <td width="200px"><input type="text" name="password" value="<?php echo $arr_user->password?>"></td>
    <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 align="right"><td colspan="2"><input type="submit" value="Save"></td></tr>