home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Master Visually: Macrome…a Dreamweaver 8 & Flash 8
/
MasterVisuallyDreamweaver8AndFlash8.iso
/
mac
/
Samples
/
ch16
/
display_results.php
< prev
next >
Wrap
PHP Script
|
2005-12-28
|
2KB
|
53 lines
<?php require_once('Connections/cxn_test2.php'); ?>
<?php
$maxRows_search_results = 5;
$pageNum_search_results = 0;
if (isset($_GET['pageNum_search_results'])) {
$pageNum_search_results = $_GET['pageNum_search_results'];
}
$startRow_search_results = $pageNum_search_results * $maxRows_search_results;
$colname_search_results = "-1";
if (isset($_POST['searchTerm'])) {
$colname_search_results = (get_magic_quotes_gpc()) ? $_POST['searchTerm'] : addslashes($_POST['searchTerm']);
}
mysql_select_db($database_cxn_test2, $cxn_test2);
$query_search_results = sprintf("SELECT custID, last_name, email FROM customer WHERE last_name = '%s'", $colname_search_results);
$query_limit_search_results = sprintf("%s LIMIT %d, %d", $query_search_results, $startRow_search_results, $maxRows_search_results);
$search_results = mysql_query($query_limit_search_results, $cxn_test2) or die(mysql_error());
$row_search_results = mysql_fetch_assoc($search_results);
if (isset($_GET['totalRows_search_results'])) {
$totalRows_search_results = $_GET['totalRows_search_results'];
} else {
$all_search_results = mysql_query($query_search_results);
$totalRows_search_results = mysql_num_rows($all_search_results);
}
$totalPages_search_results = ceil($totalRows_search_results/$maxRows_search_results)-1;
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Display results</title>
</head>
<body>
<table border="1" cellpadding="5" cellspacing="5">
<tr>
<td>custID</td>
<td>last_name</td>
<td>email</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_search_results['custID']; ?></td>
<td><?php echo $row_search_results['last_name']; ?></td>
<td><?php echo $row_search_results['email']; ?></td>
</tr>
<?php } while ($row_search_results = mysql_fetch_assoc($search_results)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($search_results);
?>