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 >
PHP Script  |  2005-12-28  |  2KB  |  53 lines

  1. <?php require_once('Connections/cxn_test2.php'); ?>
  2. <?php
  3. $maxRows_search_results = 5;
  4. $pageNum_search_results = 0;
  5. if (isset($_GET['pageNum_search_results'])) {
  6.   $pageNum_search_results = $_GET['pageNum_search_results'];
  7. }
  8. $startRow_search_results = $pageNum_search_results * $maxRows_search_results;
  9.  
  10. $colname_search_results = "-1";
  11. if (isset($_POST['searchTerm'])) {
  12.   $colname_search_results = (get_magic_quotes_gpc()) ? $_POST['searchTerm'] : addslashes($_POST['searchTerm']);
  13. }
  14. mysql_select_db($database_cxn_test2, $cxn_test2);
  15. $query_search_results = sprintf("SELECT custID, last_name, email FROM customer WHERE last_name = '%s'", $colname_search_results);
  16. $query_limit_search_results = sprintf("%s LIMIT %d, %d", $query_search_results, $startRow_search_results, $maxRows_search_results);
  17. $search_results = mysql_query($query_limit_search_results, $cxn_test2) or die(mysql_error());
  18. $row_search_results = mysql_fetch_assoc($search_results);
  19.  
  20. if (isset($_GET['totalRows_search_results'])) {
  21.   $totalRows_search_results = $_GET['totalRows_search_results'];
  22. } else {
  23.   $all_search_results = mysql_query($query_search_results);
  24.   $totalRows_search_results = mysql_num_rows($all_search_results);
  25. }
  26. $totalPages_search_results = ceil($totalRows_search_results/$maxRows_search_results)-1;
  27. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  28. <html xmlns="http://www.w3.org/1999/xhtml">
  29. <head>
  30. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  31. <title>Display results</title>
  32. </head>
  33.  
  34. <body>
  35. <table border="1" cellpadding="5" cellspacing="5">
  36.   <tr>
  37.     <td>custID</td>
  38.     <td>last_name</td>
  39.     <td>email</td>
  40.   </tr>
  41.   <?php do { ?>
  42.     <tr>
  43.       <td><?php echo $row_search_results['custID']; ?></td>
  44.       <td><?php echo $row_search_results['last_name']; ?></td>
  45.       <td><?php echo $row_search_results['email']; ?></td>
  46.     </tr>
  47.     <?php } while ($row_search_results = mysql_fetch_assoc($search_results)); ?>
  48. </table>
  49. </body>
  50. </html>
  51. <?php
  52. mysql_free_result($search_results);
  53. ?>