Hi,
I have a Search page with 4 list menus where the user can select an option from ANY or ALL of the menus, if a menu is not selected the value posted to the results page will be 'zzz'.
On the results page I have 4 recordsets, all getting the correct results, only one recordset is required to run depending on how many of the menus from the search page have been selected and a test is run before executing the sql using a SWITCH statement checking how many of the menus had passed the 'zzz' values from the Search page if you see what I mean.
THE PROBLEM - if all 4 menus are selected on the search page then the results display the first page correctly and the display record count shows correct results found. However the NEXT page (2nd) page is empty of results and still shows the correct display record count as if it should be displaying the records.
If 3, 2, or 1 menus selected from Search then again all results on the first page are correct along with the record displaycount, however the NEXT page shows results from the DEFAULT setting of the recordset and the Display record count reflects this new set of results.
Looking forward to any help.
$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 = "pr9";
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 DISTINCT ...... 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"));
$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); } ?>
$maxRows_RsSearchForSale2 = 10;
$pageNum_RsSearchForSale2 = 0;
if (isset($GET['pageNum_RsSearchForSale2'])) {
$pageNum_RsSearchForSale2 = $GET['pageNum_RsSearchForSale2'];
}
$startRow_RsSearchForSale2 = $pageNum_RsSearchForSale2 * $maxRows_RsSearchForSale2;
$varloc2_RsSearchForSale2 = "mpl";
if (isset($POST['location'])) {
$varloc2_RsSearchForSale2 = $POST['location'];
}
$varprice2_RsSearchForSale2 = "p9";
if (isset($POST['price'])) {
$varprice2_RsSearchForSale2 = $POST['price'];
}
$vartype2_RsSearchForSale2 = "vil";
if (isset($POST['type'])) {
$vartype2_RsSearchForSale2 = $POST['type'];
}
$varbed2_RsSearchForSale2 = "b5";
if (isset($POST['beds'])) {
$varbed2_RsSearchForSale2 = $POST['beds'];
}
switch (true) {
case ($varloc2_RsSearchForSale2 == 'zzz'):
case ($varprice2_RsSearchForSale2 == 'zzz'):
case ($vartype2_RsSearchForSale2 == 'zzz'):
case ($varbed2_RsSearchForSale2 == 'zzz'):
mysql_select_db($database_propertypages, $propertypages);
$query_RsSearchForSale2 = sprintf("SELECT DISTINCT ... WHERE (location=%s AND price=%s AND type=%s) OR (location=%s AND price=%s AND beds=%s) OR (location=%s AND type=%s AND beds=%s) OR (price=%s AND type=%s AND beds=%s) ORDER BY detailstable.trueprice ASC", GetSQLValueString($varloc2_RsSearchForSale2, "text"),GetSQLValueString($varprice2_RsSearchForSale2, "text"),GetSQLValueString($vartype2_RsSearchForSale2, "text"),GetSQLValueString($varloc2_RsSearchForSale2, "text"),GetSQLValueString($varprice2_RsSearchForSale2, "text"),GetSQLValueString($varbed2_RsSearchForSale2, "text"),GetSQLValueString($varloc2_RsSearchForSale2, "text"),GetSQLValueString($vartype2_RsSearchForSale2, "text"),GetSQLValueString($varbed2_RsSearchForSale2, "text"),GetSQLValueString($varprice2_RsSearchForSale2, "text"),GetSQLValueString($vartype2_RsSearchForSale2, "text"),GetSQLValueString($varbed2_RsSearchForSale2, "text"));
$query_limit_RsSearchForSale2 = sprintf("%s LIMIT %d, %d", $query_RsSearchForSale2, $startRow_RsSearchForSale2, $maxRows_RsSearchForSale2);
$RsSearchForSale2 = mysql_query($query_limit_RsSearchForSale2, $propertypages) or die(mysql_error());
$row_RsSearchForSale2 = mysql_fetch_assoc($RsSearchForSale2);
if (isset($GET['totalRows_RsSearchForSale2'])) {
$totalRows_RsSearchForSale2 = $GET['totalRows_RsSearchForSale2'];
} else {
$all_RsSearchForSale2 = mysql_query($query_RsSearchForSale2);
$totalRows_RsSearchForSale2 = mysql_num_rows($all_RsSearchForSale2);
}
$totalPages_RsSearchForSale2 = ceil($totalRows_RsSearchForSale2/$maxRows_RsSearchForSale2)-1;
$queryString_RsSearchForSale2 = "";
if (!empty($SERVER['QUERY_STRING'])) {
$params = explode("&", $SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_RsSearchForSale2") == false &&
stristr($param, "totalRows_RsSearchForSale2") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_RsSearchForSale2 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_RsSearchForSale2 = sprintf("&totalRows_RsSearchForSale2=%d%s", $totalRows_RsSearchForSale2, $queryString_RsSearchForSale2);
}?>
[\code]
I do the same code repeated for the next 2 recordsets just a different switch statement checking how many menus selected.
<?php do { ?>
<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>Ref : <?php echo $row_RSsearchforsale['propid']; ?></p>
<p><?php echo $row_RSsearchforsale['desc']; ?></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 } while ($row_RSsearchforsale = mysql_fetch_assoc($RSsearchforsale)); ?><p>
<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>
Again recordsets results for search 2,3, & 4 displayed in same way as above.