Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Building Complex Searches EGD CS4 page 776

New Here ,
Jan 19, 2011 Jan 19, 2011

Copy link to clipboard

Copied

I have followed David Powers book The Essential Guide to Dreamweaver CS4 etc and built a working complex search - wonderful.

The only problem is that the Repeat region shows all results rather than the required 10 at a time.

I have tried importing the code from a standard Recordset search page but it still shows the full list.

Page code follows

Thanks to anyone who can help

<?php require_once('Connections/cornwallQuery.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;   
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_getList = 10;
$pageNum_getList = 0;
if (isset($_GET['pageNum_getList'])) {
  $pageNum_getList = $_GET['pageNum_getList'];
}
$startRow_getList = $pageNum_getList * $maxRows_getList;

$var1_getList = "-1";
if (isset($_GET['searchSubCat'])) {
  $var1_getList = $_GET['searchSubCat'];
}

mysql_select_db($database_cornwallQuery, $cornwallQuery);
$query_getList = sprintf("SELECT Name, Address1, Address2, Pcode, Phone, Details, Ctowns.Town FROM List LEFT JOIN Ctowns USING (TownID)");
$where = false;
if (isset($_GET['towns_menu']) && !empty($_GET['towns_menu'])) {
  $query_getList .= sprintf(" WHERE Ctowns.TownID = %s", GetSQLValueString($_GET['towns_menu'], "int"));
  $where = true;
}
if (isset($_GET['searchSubCat']) && !empty($_GET['searchSubCat'])) {
  if ($where) {
    $query_getList .= ' AND ';
  } else {
    $query_getList .= ' WHERE ';
    $where = true;
  }
  $query_getList .= sprintf(" List.SubCatID = %s", GetSQLValueString($_GET['searchSubCat'], "int"));
}

$query_getList .= " ORDER BY List.Name";
$getList = mysql_query($query_getList, $cornwallQuery) or die(mysql_error());
$row_getList = mysql_fetch_assoc($getList);

if (isset($_GET['totalRows_getList'])) {
  $totalRows_getList = $_GET['totalRows_getList'];
} else {
  $all_getList = mysql_query($query_getList);
  $totalRows_getList = mysql_num_rows($all_getList);
}
$totalPages_getList = ceil($totalRows_getList/$maxRows_getList)-1;

$queryString_getList = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_getList") == false &&
        stristr($param, "totalRows_getList") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_getList = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_getList = sprintf("&totalRows_getList=%d%s", $totalRows_getList, $queryString_getList);
?>
<!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=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<div id="content">     <h3>Your exploration results</h3>
   
      <div align="center">
        <table width="500" cellpadding="4" id="striped">
          <tr>
            <th scope="col">Name</th>
            <th scope="col">Phone</th>
            <th scope="col">Details</th>
          </tr>
           <?php do { ?>
    <tr>
      <td><p><?php echo $row_getList['Name']; ?><br />
        <?php echo $row_getList['Address1']; ?> <br />
        <?php echo $row_getList['Address2']; ?> <br />
        <?php echo $row_getList['Town']; ?> <br />
      </p></td>
      <td>  <?php echo $row_getList['Phone']; ?></td>
      <td><a href="exploreD.php?recordID=<?php echo $row_getList['ListID']; ?>"><?php echo $row_getList['Details']; ?></a></td>
      </tr>
    <?php } while ($row_getList = mysql_fetch_assoc($getList)); ?>
</table>
<br />
<table border="0">
  <tr>
    <td><?php if ($pageNum_getList > 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pageNum_getList=%d%s", $currentPage, 0, $queryString_getList); ?>">First</a>
        <?php } // Show if not first page ?></td>
    <td><?php if ($pageNum_getList > 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pageNum_getList=%d%s", $currentPage, max(0, $pageNum_getList - 1), $queryString_getList); ?>">Previous</a>
        <?php } // Show if not first page ?></td>
    <td><?php if ($pageNum_getList < $totalPages_getList) { // Show if not last page ?>
        <a href="<?php printf("%s?pageNum_getList=%d%s", $currentPage, min($totalPages_getList, $pageNum_getList + 1), $queryString_getList); ?>">Next</a>
        <?php } // Show if not last page ?></td>
    <td><?php if ($pageNum_getList < $totalPages_getList) { // Show if not last page ?>
        <a href="<?php printf("%s?pageNum_getList=%d%s", $currentPage, $totalPages_getList, $queryString_getList); ?>">Last</a>
        <?php } // Show if not last page ?></td>
  </tr>
</table>
<p class="feature">Records <?php echo ($startRow_getList + 1) ?> to <?php echo min($startRow_getList + $maxRows_getList, $totalRows_getList) ?> of <?php echo $totalRows_getList ?></p>
            <td class="resultsTable"></td>
            <td class="resultsTable"></tr></td>
          <?php if ($totalRows_getList == 0) { // Show if recordset empty ?>
  <p class="warning">Sorry, we don't have any records as yet to match your request.<br />
    Our database is continually growing,<br />
    so please try again another day.<br />
    Thank you.
    <?php } // Show if recordset empty ?>

        <p class="feature"><a href="explore.php">Search Again</a></p>
    </div>
      <div align="center"></div>
  </div>
  <!-- end #content -->
 
</div>

</body>
</html>
<?php
mysql_free_result($getList);
?>

TOPICS
Server side applications

Views

240
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 20, 2011 Jan 20, 2011

Copy link to clipboard

Copied

LATEST

Ah! Found some missing code.

Thanks to any and all who considered this error.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines