User's Manual

Extending the Basic Employee Form
Beta Draft Updating Data 5-3
function construct_employees()
{
$query =
"SELECT employee_id,
substr(first_name,1,1) || '. '|| last_name as employee_name,
hire_date,
to_char(salary, '9999G999D99') as salary,
nvl(commission_pct,0) as commission_pct
FROM employees
ORDER BY employee_id asc";
$conn = db_connect();
$emp = db_do_query($conn, $query, OCI_FETCHSTATEMENT_BY_ROW);
ui_print_header('Employees');
ui_print_employees($emp, $_SERVER['SCRIPT_NAME']);
ui_print_footer(date('Y-m-d H:i:s'));
}
5. Edit anyco.php. Add insert_new_emp() to insert an employee into the
EMPLOYEES table:
function insert_new_emp()
{
$newemp = $_POST;
$statement =
"INSERT INTO employees
(employee_id, first_name, last_name, email, hire_date,
job_id, salary, commission_pct, department_id)
VALUES (employees_seq.nextval, :fnm, :lnm, :eml, :hdt, :jid,
:sal, :cpt, :did)";
$conn = db_connect();
$emailid = $newemp['firstname'].$newemp['lastname'];
$bindargs = array();
array_push($bindargs, array('FNM', $newemp['firstname'], -1));
array_push($bindargs, array('LNM', $newemp['lastname'], -1));
array_push($bindargs, array('EML', $emailid, -1));
array_push($bindargs, array('HDT', $newemp['hiredate'], -1));
array_push($bindargs, array('JID', $newemp['jobid'], -1));
array_push($bindargs, array('SAL', $newemp['salary'], -1));
array_push($bindargs, array('CPT', $newemp['commpct'], -1));
array_push($bindargs, array('DID', $newemp['deptid'], -1));
$r = db_execute_statement($conn, $statement, $bindargs);
construct_employees();
}
The return value from db_execute_statement() is ignored and not even
assigned to a variable, because we don't perform any action on its result until later.
6. Edit anyco.php. Add construct_modify_emp() to build the HTML form for
updating an employee.
function construct_modify_emp()
{
$empid = $_POST['emprec'];
$query =
"SELECT employee_id, first_name, last_name, email, hire_date,
salary, nvl(commission_pct,0) as commission_pct