Here is the file named showEditableEmps.php, which will be included whenever we want to display the employee information and allow add/edit/delete of employees.
<p>
<a href="add_one_employee.php">Add an employee</a>
</p>
<table border="1">
<caption>Employees</caption>
<tr>
<th>Action
<th>Last Name
<th>First Name
<th>Birth Date
<th>Is Admin?
</tr>
<?php
// Connect to the database and get the data of interest
$db = odbc_connect("iaidb", "css_test", "password") or die ("could not connect<br />");
$stmt = "Select EmployeeNumber, LastName, FirstName, BirthDate, IsAdmin from tblEmployees";
$result = odbc_exec($db, $stmt);
if ($result == FALSE) die ("could not execute statement $stmt<br />");
// Populate the rows of the table with the data
while (odbc_fetch_row($result))
{
$id = odbc_result($result, "EmployeeNumber");
print "<tr>\n";
print ' <td><a href="edit_one_emp.php?id='.$id.'">Edit<a> or '.
'<a href="del_one_emp.php?id='.$id.'">Delete</a>'."\n";
print ' <td>'.odbc_result($result, "lastname")."\n";
print ' <td>'.odbc_result($result, "firstname")."\n";
print ' <td>'.odbc_result($result, "birthdate")."\n";
print ' <td>'.odbc_result($result, "isadmin")."\n";
print "</tr>\n";
}
?>
</table>