Help with dynamic search results only displays 1 page
Posted: Tue Nov 10, 2009 9:20 am
Hi,
I have set up a dynamic search & results page and the correct records are being retreived and displayed, but only on the first page. I have set up the results to display the first 10 records then the user would have to click NEXT to get to the next page of records, however this page is empty of results but at the top of the page i have the total records found and the results from 1 to 10, and 11 to 20 etc and these do reflect the number of relevant records in the database, so why are there no records displayed in the next page? Any ideas out there?
I have set up a dynamic search & results page and the correct records are being retreived and displayed, but only on the first page. I have set up the results to display the first 10 records then the user would have to click NEXT to get to the next page of records, however this page is empty of results but at the top of the page i have the total records found and the results from 1 to 10, and 11 to 20 etc and these do reflect the number of relevant records in the database, so why are there no records displayed in the next page? Any ideas out there?
Code: Select all
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_RSsearchforsale = 10;
$pageNum_RSsearchforsale = 0;
if (isset($_GET['pageNum_RSsearchforsale'])) {
$pageNum_RSsearchforsale = $_GET['pageNum_RSsearchforsale'];
}
$startRow_RSsearchforsale = $pageNum_RSsearchforsale * $maxRows_RSsearchforsale;
$varloc_RSsearchforsale = "mpl";
if (isset($_POST['location'])) {
$varloc_RSsearchforsale = $_POST['location'];
}
$vartype_RSsearchforsale = "vil";
if (isset($_POST['type'])) {
$vartype_RSsearchforsale = $_POST['type'];
}
$varprice_RSsearchforsale = "p9";
if (isset($_POST['price'])) {
$varprice_RSsearchforsale = $_POST['price'];
}
$varbed_RSsearchforsale = "b5";
if (isset($_POST['beds'])) {
$varbed_RSsearchforsale = $_POST['beds'];
}
switch (true) {
case ($varloc_RSsearchforsale != 'zzz' && $vartype_RSsearchforsale != 'zzz' && $varprice_RSsearchforsale != 'zzz' && $varbed_RSsearchforsale!= 'zzz'):
mysql_select_db($database_propertypages, $propertypages);
$query_RSsearchforsale = sprintf("SELECT trueprice,`desc`, `propid`, `bathrooms`, `photo1`, locationtable.loc, typetable.style, bedtable.`number` FROM detailstable JOIN locationtable ON detailstable.location=locationtable.locid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid WHERE location=%s AND price = %s AND type=%s AND beds=%s ORDER BY detailstable.trueprice ASC", GetSQLValueString($varloc_RSsearchforsale, "text"),GetSQLValueString($varprice_RSsearchforsale, "text"),GetSQLValueString($vartype_RSsearchforsale, "text"),GetSQLValueString($varbed_RSsearchforsale, "text")); }
switch (true) {
case ($varloc_RSsearchforsale == 'zzz'):
case ($vartype_RSsearchforsale == 'zzz'):
case ($varprice_RSsearchforsale == 'zzz'):
case ($varbed_RSsearchforsale == 'zzz'):
mysql_select_db($database_propertypages, $propertypages);
$query_RSsearchforsale = sprintf("SELECT trueprice,`desc`, `propid`, `bathrooms`, `photo1`, locationtable.loc, typetable.style, bedtable.`number` FROM detailstable JOIN locationtable ON detailstable.location=locationtable.locid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid WHERE (price=%s AND location=%s AND type=%s) OR (price=%s AND location=%s AND beds=%s) OR (price=%s AND beds=%s AND type=%s) OR ( location=%s AND type=%s AND beds=%s) ORDER BY detailstable.trueprice ASC", GetSQLValueString($varprice_RSsearchforsale, "text"),GetSQLValueString($varloc_RSsearchforsale, "text"),GetSQLValueString($vartype_RSsearchforsale, "text"),GetSQLValueString($varprice_RSsearchforsale, "text"),GetSQLValueString($varloc_RSsearchforsale, "text"),GetSQLValueString($varbed_RSsearchforsale, "text"),GetSQLValueString($varprice_RSsearchforsale, "text"),GetSQLValueString($varbed_RSsearchforsale, "text"),GetSQLValueString($vartype_RSsearchforsale, "text"),GetSQLValueString($varloc_RSsearchforsale, "text"),GetSQLValueString($vartype_RSsearchforsale, "text"),GetSQLValueString($varbed_RSsearchforsale, "text")); }
switch (true) {
case ($varloc_RSsearchforsale == 'zzz' && $vartype_RSsearchforsale == 'zzz'):
case ($varloc_RSsearchforsale == 'zzz' && $varprice_RSsearchforsale == 'zzz'):
case ($varloc_RSsearchforsale == 'zzz' && $varbed_RSsearchforsale == 'zzz'):
case ($vartype_RSsearchforsale == 'zzz' && $varprice_RSsearchforsale == 'zzz'):
case ($vartype_RSsearchforsale == 'zzz' && $varbed_RSsearchforsale == 'zzz'):
case ($varprice_RSsearchforsale == 'zzz' && $varbed_RSsearchforsale == 'zzz'):
mysql_select_db($database_propertypages, $propertypages);
$query_RSsearchforsale = sprintf("SELECT trueprice,`desc`, `propid`, `bathrooms`, `photo1`, locationtable.loc, typetable.style, bedtable.`number` FROM detailstable JOIN locationtable ON detailstable.location=locationtable.locid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid WHERE (price=%s AND location=%s) OR (price=%s AND type=%s) OR (price=%s AND beds=%s) OR (type=%s AND location=%s) OR (type=%s AND beds=%s) OR (location=%s AND beds=%s) ORDER BY detailstable.trueprice ASC", GetSQLValueString($varprice_RSsearchforsale, "text"),GetSQLValueString($varloc_RSsearchforsale, "text"),GetSQLValueString($varprice_RSsearchforsale, "text"),GetSQLValueString($vartype_RSsearchforsale, "text"),GetSQLValueString($varprice_RSsearchforsale, "text"),GetSQLValueString($varbed_RSsearchforsale, "text"),GetSQLValueString($vartype_RSsearchforsale, "text"),GetSQLValueString($varloc_RSsearchforsale, "text"),GetSQLValueString($vartype_RSsearchforsale, "text"),GetSQLValueString($varbed_RSsearchforsale, "text"),GetSQLValueString($varloc_RSsearchforsale, "text"),GetSQLValueString($varbed_RSsearchforsale, "text")); }
switch (true) {
case ($varloc_RSsearchforsale == 'zzz' && $vartype_RSsearchforsale == 'zzz' && $varprice_RSsearchforsale == 'zzz'):
case ($varloc_RSsearchforsale == 'zzz' && $vartype_RSsearchforsale == 'zzz' && $varbed_RSsearchforsale == 'zzz'):
case ($vartype_RSsearchforsale == 'zzz' && $varbed_RSsearchforsale == 'zzz' && $varprice_RSsearchforsale == 'zzz'):
case ($varbed_RSsearchforsale == 'zzz' && $varprice_RSsearchforsale == 'zzz' && $varloc_RSsearchforsale == 'zzz' ):
mysql_select_db($database_propertypages, $propertypages);
$query_RSsearchforsale = sprintf("SELECT trueprice,`desc`, `propid`, `bathrooms`, `photo1`, locationtable.loc, typetable.style, bedtable.`number` FROM detailstable JOIN locationtable ON detailstable.location=locationtable.locid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid WHERE price = %s OR beds=%s OR type=%s OR location=%s ORDER BY detailstable.trueprice ASC", GetSQLValueString($varprice_RSsearchforsale, "text"),GetSQLValueString($varbed_RSsearchforsale, "text"),GetSQLValueString($vartype_RSsearchforsale, "text"),GetSQLValueString($varloc_RSsearchforsale, "text"));}
$query_limit_RSsearchforsale = sprintf("%s LIMIT %d, %d", $query_RSsearchforsale, $startRow_RSsearchforsale, $maxRows_RSsearchforsale);
$RSsearchforsale = mysql_query($query_limit_RSsearchforsale, $propertypages) or die(mysql_error());
$row_RSsearchforsale = mysql_fetch_assoc($RSsearchforsale);
if (isset($_GET['totalRows_RSsearchforsale'])) {
$totalRows_RSsearchforsale = $_GET['totalRows_RSsearchforsale'];
} else {
$all_RSsearchforsale = mysql_query($query_RSsearchforsale);
$totalRows_RSsearchforsale = mysql_num_rows($all_RSsearchforsale);
}
$totalPages_RSsearchforsale = ceil($totalRows_RSsearchforsale/$maxRows_RSsearchforsale)-1;
$queryString_RSsearchforsale = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_RSsearchforsale") == false &&
stristr($param, "totalRows_RSsearchforsale") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_RSsearchforsale = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_RSsearchforsale = sprintf("&totalRows_RSsearchforsale=%d%s", $totalRows_RSsearchforsale, $queryString_RSsearchforsale);
?>
<div id="mainContent">
<p class="records">SEARCH RESULTS</p>
<p class="records">Found <?php echo $totalRows_RSsearchforsale ?></p>
<?php if ($totalRows_RSsearchforsale > 0) { // Show if recordset not empty ?>
<p class="Propertiesright">Properties <?php echo ($startRow_RSsearchforsale + 1) ?> to <?php echo min($startRow_RSsearchforsale + $maxRows_RSsearchforsale, $totalRows_RSsearchforsale) ?></p>
<?php } // Show if recordset not empty ?>
<p> </p>
<p> </p>
<?php do { ?>
<?php if ($totalRows_RSsearchforsale > 0) { // Show if recordset not empty ?>
<div id="salesresults">
<p><img src="PhotosResults/<?php echo $row_RSsearchforsale['photo1']; ?>" alt="Photo Property For Sale" class="imageleft" /><span class="pararightloc"><?php echo $row_RSsearchforsale['loc']; ?></span><span class="price"><?php echo $row_RSsearchforsale['trueprice']; ?> €</span></p>
<div id="topborder">
<p><span class="location"><?php echo $row_RSsearchforsale['style']; ?></span><span class="lineheight"><?php echo $row_RSsearchforsale['number']; ?> Beds</span> <span class="space"><?php echo $row_RSsearchforsale['bathrooms']; ?>Baths </span></p>
</div>
<p> </p>
<p>Ref : <?php echo $row_RSsearchforsale['propid']; ?></p>
<p> </p>
<p><?php echo $row_RSsearchforsale['desc']; ?></p>
<p> </p>
<p> </p>
<p><span class="space"><a href="detailsForSale.php?propid=<?php echo $row_RSsearchforsale['propid']; ?>" class="moreinfo">More Info</a></span> </p>
<p> </p>
</div>
<?php } // Show if recordset not empty ?>
<?php } while ($row_RSsearchforsale = mysql_fetch_assoc($RSsearchforsale)); ?><p>
<p>
<?php if ($totalRows_RSsearchforsale == 0) { // Show if recordset empty ?>
</p>
<div id="noResults">
<p>There were no results found for your search. </p>
<p>Please try again with new criteria.</p>
<p> </p>
</div>
<?php } // Show if recordset empty ?>
<?php if ($totalRows_RSsearchforsale > 0) { // Show if recordset not empty ?>
<div id="navigate">
<span class="records">Page Navigation</span>
<table border="0" class="centralise">
<tr>
<td><?php if ($pageNum_RSsearchforsale > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_RSsearchforsale=%d%s", $currentPage, 0, $queryString_RSsearchforsale); ?>">First</a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_RSsearchforsale > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_RSsearchforsale=%d%s", $currentPage, max(0, $pageNum_RSsearchforsale - 1), $queryString_RSsearchforsale); ?>">Previous</a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_RSsearchforsale < $totalPages_RSsearchforsale) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_RSsearchforsale=%d%s", $currentPage, min($totalPages_RSsearchforsale, $pageNum_RSsearchforsale + 1), $queryString_RSsearchforsale); ?>">Next</a>
<?php } // Show if not last page ?> </td>
<td><?php if ($pageNum_RSsearchforsale < $totalPages_RSsearchforsale) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_RSsearchforsale=%d%s", $currentPage, $totalPages_RSsearchforsale, $queryString_RSsearchforsale); ?>">Last</a>
<?php } // Show if not last page ?> </td>
</tr>
</table>
</div>
<?php } // Show if recordset not empty ?>
</p>
</div>