Prev | Current Page 38 | Next

Larry Ullman

"Building a Web Site with Ajax: Visual QuickProject Guide"

php
$did = 0;
if (isset($_GET[???did??™])) {
$did = (int) $_GET[???did??™];
}
if ($did > 0) {
} else { // Invalid department ID!
echo ???

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??™]}

\n???;
} // End of WHILE loop.


Pages:
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50