Prev | Current Page 80 | Next

Larry Ullman

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


css???;


Employee Search Results


?>


92 creating a search
query the database
1 We make sure that some value was submitted for the
last name or else there??™s no need to query the database.
2 The MySQL connection script is included.
3 The query
will return every
employee??™s name,
email address,
and department
whose last name
begins with the
submitted letters.
(See extra bits on page 97.)
4 The mysql_real_escape_string() function
makes it safe to use the submitted value in a query.
??¦
if (!empty($_GET[???last_name??™])) {
require_once(???mysql.inc.php??™);
$q = ???SELECT CONCAT(last_name, ???, ???, first_name),
email, department FROM employees LEFT JOIN departments
USING (department_id) WHERE last_name LIKE ?????? . mysql_
real_escape_string($_GET[???last_name??™]) . ???%??™ ORDER BY
last_name, first_name???;
$r = mysql_query($q, $dbc);
?>
??¦
creating a search 93
print the results
1 Check that at least one record was returned.
2 Fetch all the records and
print them out.


Pages:
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92