Please select a valid department
from the drop-down menu in order to view its employees.
p>??™;
}
?>
32 browsing using Ajax
print the employees
The PHP page prints the list of employees in the given department. To do so,
a database query is required. (See extra bits on page 41.)
3 Fetch any returned records and print them with a little
bit of HTML and CSS formatting.
1 Include the database connection script (written in
the previous chapter).
2 Query the database, looking for employees in the
given department.
??¦
if ($did > 0) {
require_once(???mysql.inc.php??™);
$q = ???SELECT * FROM employees WHERE department_
id=$did ORDER BY last_name, first_name???;
$r = mysql_query($q, $dbc);
while ($row = mysql_fetch_array($r, MYSQL_ASSOC)) {
echo ???
{$row[???last_name??™]},
{$row[???first_name??™]}
Email: {$row[???email??™]}
Phone Extension: {$row[???phone_ext??™]}