Prev | Current Page 24 | Next

Larry Ullman

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

php and placed in the
same directory as dept_form.html.
browsing employees 15
??¦
$did = 0;
if (isset($_GET[???did??™])) {
$did = (int) $_GET[???did??™];
}
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);
if (mysql_num_rows($r) > 0) {
while ($row = mysql_fetch_array($r, MYSQL_ASSOC))
{
echo ???

{$row[???last_
name??™]}, {$row[???first_name??™]}


Email: {$row[???email??™]}

Phone Extension: {$row[???phone_
ext??™]}

\n???;
}
print the employees
1 Within the PHP tags, start by making sure that a valid department
ID was received. The department ID must be an integer
greater than 0. (See extra bits on page 23.)
2 Then include the database connection script (to be written next).
3 Query the database, looking for employees in the given department.
4 Fetch any returned records and print them with a little bit of
HTML and CSS formatting.
16 browsing employees
??¦

\n???;
}
} else {
echo ???

There are no employees
listed for the given department.


Pages:
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36