Hi,
I have created a statement using IF, ELSE IFs, ELSE, and it brings up PARSE ERROR UNEXPECTED T_ELSEIF in line...
On checking for the solution to this error it often seems that a } has been included or missed, i´ve doubled checked my code and don´t think that this is the problem, so why doesn´t my code work? Hope someone can help me, i´m just learning php so you probably think my code is a little repeatative but i can look to improve on that if i can just get it to work.
I´m basically doing a search from 4 list menus and depending on which menus the users selections an option from i want to run a different set of results hence the IF, ELSIF ELSE clause.
Code is below, i´ve included all php code on the results page, the IF, ELSEIF, ELSE statement starts just under the dotted line.
Look forward to any help.
<?php require_once('Connections/propertypages.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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_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'];
}
mysql_select_db($database_propertypages, $propertypages);
$query_RSsearchforsale = sprintf("SELECT DISTINCT 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"));
$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;
$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'];
}
mysql_select_db($database_propertypages, $propertypages);
$query_RsSearchForSale2 = sprintf("SELECT DISTINCT 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) 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;
$maxRows_RsSearchForSale3 = 10;
$pageNum_RsSearchForSale3 = 0;
if (isset($_GET['pageNum_RsSearchForSale3'])) {
$pageNum_RsSearchForSale3 = $_GET['pageNum_RsSearchForSale3'];
}
$startRow_RsSearchForSale3 = $pageNum_RsSearchForSale3 * $maxRows_RsSearchForSale3;
$varloc3_RsSearchForSale3 = "mpl";
if (isset($_POST['location'])) {
$varloc3_RsSearchForSale3 = $_POST['location'];
}
$varprice3_RsSearchForSale3 = "p9";
if (isset($_POST['price'])) {
$varprice3_RsSearchForSale3 = $_POST['price'];
}
$vartype3_RsSearchForSale3 = "vil";
if (isset($_POST['type'])) {
$vartype3_RsSearchForSale3 = $_POST['type'];
}
$varbed3_RsSearchForSale3 = "b5";
if (isset($_POST['beds'])) {
$varbed3_RsSearchForSale3 = $_POST['beds'];
}
mysql_select_db($database_propertypages, $propertypages);
$query_RsSearchForSale3 = sprintf("SELECT DISTINCT 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) OR (location=%s AND type=%s) OR (location=%s AND beds=%s) OR ( type=%s AND beds=%s) OR (price=%s AND type=%s) OR (price=%s AND beds=%s) ORDER BY detailstable.trueprice ASC", GetSQLValueString($varloc3_RsSearchForSale3, "text"),GetSQLValueString($varprice3_RsSearchForSale3, "text"),GetSQLValueString($varloc3_RsSearchForSale3, "text"),GetSQLValueString($vartype3_RsSearchForSale3, "text"),GetSQLValueString($varloc3_RsSearchForSale3, "text"),GetSQLValueString($varbed3_RsSearchForSale3, "text"),GetSQLValueString($vartype3_RsSearchForSale3, "text"),GetSQLValueString($varbed3_RsSearchForSale3, "text"),GetSQLValueString($varprice3_RsSearchForSale3, "text"),GetSQLValueString($vartype3_RsSearchForSale3, "text"),GetSQLValueString($varprice3_RsSearchForSale3, "text"),GetSQLValueString($varbed3_RsSearchForSale3, "text"));
$query_limit_RsSearchForSale3 = sprintf("%s LIMIT %d, %d", $query_RsSearchForSale3, $startRow_RsSearchForSale3, $maxRows_RsSearchForSale3);
$RsSearchForSale3 = mysql_query($query_limit_RsSearchForSale3, $propertypages) or die(mysql_error());
$row_RsSearchForSale3 = mysql_fetch_assoc($RsSearchForSale3);
if (isset($_GET['totalRows_RsSearchForSale3'])) {
$totalRows_RsSearchForSale3 = $_GET['totalRows_RsSearchForSale3'];
} else {
$all_RsSearchForSale3 = mysql_query($query_RsSearchForSale3);
$totalRows_RsSearchForSale3 = mysql_num_rows($all_RsSearchForSale3);
}
$totalPages_RsSearchForSale3 = ceil($totalRows_RsSearchForSale3/$maxRows_RsSearchForSale3)-1;
$maxRows_RsSearchForSale4 = 10;
$pageNum_RsSearchForSale4 = 0;
if (isset($_GET['pageNum_RsSearchForSale4'])) {
$pageNum_RsSearchForSale4 = $_GET['pageNum_RsSearchForSale4'];
}
$startRow_RsSearchForSale4 = $pageNum_RsSearchForSale4 * $maxRows_RsSearchForSale4;
$varloc4_RsSearchForSale4 = "mpl";
if (isset($_POST['location'])) {
$varloc4_RsSearchForSale4 = $_POST['location'];
}
$vartype4_RsSearchForSale4 = "vil";
if (isset($_POST['type'])) {
$vartype4_RsSearchForSale4 = $_POST['type'];
}
$varprice4_RsSearchForSale4 = "p9";
if (isset($_POST['price'])) {
$varprice4_RsSearchForSale4 = $_POST['price'];
}
$varbed4_RsSearchForSale4 = "b5";
if (isset($_POST['beds'])) {
$varbed4_RsSearchForSale4 = $_POST['beds'];
}
mysql_select_db($database_propertypages, $propertypages);
$query_RsSearchForSale4 = sprintf("SELECT DISTINCT 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 OR price=%s OR type=%s OR beds=%s ORDER BY detailstable.trueprice ASC", GetSQLValueString($varloc4_RsSearchForSale4, "text"),GetSQLValueString($varprice4_RsSearchForSale4, "text"),GetSQLValueString($vartype4_RsSearchForSale4, "text"),GetSQLValueString($varbed4_RsSearchForSale4, "text"));
$query_limit_RsSearchForSale4 = sprintf("%s LIMIT %d, %d", $query_RsSearchForSale4, $startRow_RsSearchForSale4, $maxRows_RsSearchForSale4);
$RsSearchForSale4 = mysql_query($query_limit_RsSearchForSale4, $propertypages) or die(mysql_error());
$row_RsSearchForSale4 = mysql_fetch_assoc($RsSearchForSale4);
if (isset($_GET['totalRows_RsSearchForSale4'])) {
$totalRows_RsSearchForSale4 = $_GET['totalRows_RsSearchForSale4'];
} else {
$all_RsSearchForSale4 = mysql_query($query_RsSearchForSale4);
$totalRows_RsSearchForSale4 = mysql_num_rows($all_RsSearchForSale4);
}
$totalPages_RsSearchForSale4 = ceil($totalRows_RsSearchForSale4/$maxRows_RsSearchForSale4)-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);
--------------------------------------HTML----------------------------------------------------------------
<div id="mainContent">
<?php if ($totalRows_RSsearchforsale > 0 )
{ // Show if recordset not empty ?>
<p class="records">SEARCH RESULTS</p>
<p class="records">Found <?php echo $totalRows_RSsearchforsale ?></p>
<p class="Propertiesright">Properties <?php echo ($startRow_RSsearchforsale + 1) ?> to <?php echo min($startRow_RSsearchforsale + $maxRows_RSsearchforsale, $totalRows_RSsearchforsale) ?></p>
<p> </p>
<p> </p>
<?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> </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 } 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>
<?php } // end of RS1 ?>
<?php elseif ($totalRows_RsSearchForSale2 > 0 ) { // Show if recordset not empty ?>
<p class="records">SEARCH RESULTS</p>
<p class="records">Found <?php echo $totalRows_RsSearchForSale2 ?></p>
<p class="Propertiesright">Properties <?php echo ($startRow_RsSearchForSale2 + 1) ?> to <?php echo min($startRow_RsSearchForSale2 + $maxRows_RsSearchForSale2, $totalRows_RsSearchForSale2) ?></p>
<p> </p>
<p> </p>
<?php do { ?>
<div id="salesresults">
<p><img src="PhotosResults/<?php echo $row_RsSearchForSale2['photo1']; ?>" alt="Photo Property For Sale" class="imageleft" /><span class="pararightloc"><?php echo $row_RsSearchForSale2['loc']; ?></span><span class="price"><?php echo $row_RsSearchForSale2['trueprice']; ?> €</span></p>
<div id="topborder">
<p><span class="location"><?php echo $row_RsSearchForSale2['style']; ?></span><span class="lineheight"><?php echo $row_RsSearchForSale2['number']; ?> Beds</span> <span class="space"><?php echo $row_RsSearchForSale2['bathrooms']; ?>Baths </span></p>
</div>
<p> </p>
<p>Ref : <?php echo $row_RsSearchForSale2['propid']; ?></p>
<p> </p>
<p><?php echo $row_RsSearchForSale2['desc']; ?></p>
<p> </p>
<p> </p>
<p><span class="space"><a href="detailsForSale.php?propid=<?php echo $row_RsSearchForSale2['propid']; ?>" class="moreinfo">More Info</a></span> </p>
<p> </p>
</div>
<?php } while ($row_RsSearchForSale2 = mysql_fetch_assoc($RsSearchForSale2)); ?><p>
<div id="navigate">
<span class="records">Page Navigation</span>
<table border="0" class="centralise">
<tr>
<td><?php if ($pageNum_RsSearchForSale2 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale2=%d%s", $currentPage, 0, $queryString_RsSearchForSale2); ?>">First</a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_RsSearchForSale2 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale2=%d%s", $currentPage, max(0, $pageNum_RsSearchForSale2 - 1), $queryString_RsSearchForSale2); ?>">Previous</a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_RsSearchForSale2 < $totalPages_RsSearchForSale2) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale2=%d%s", $currentPage, min($totalPages_RsSearchForSale2, $pageNum_RsSearchForSale2 + 1), $queryString_RsSearchForSale2); ?>">Next</a>
<?php } // Show if not last page ?> </td>
<td><?php if ($pageNum_RsSearchForSale2 < $totalPages_RsSearchForSale2) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale2=%d%s", $currentPage, $totalPages_RsSearchForSale2, $queryString_RsSearchForSale2); ?>">Last</a>
<?php } // Show if not last page ?> </td>
</tr>
</table>
</div>
<?php } // End RS2 Show if recordset not empty ?>
<?php elseif ($totalRows_RsSearchForSale3 > 0 ) { // Show if recordset not empty ?>
<p class="records">SEARCH RESULTS</p>
<p class="records">Found <?php echo $totalRows_RsSearchForSale3 ?></p>
<p class="Propertiesright">Properties <?php echo ($startRow_RsSearchForSale3 + 1) ?> to <?php echo min($startRow_RsSearchForSale3 + $maxRows_RsSearchForSale3, $totalRows_RsSearchForSale3) ?></p>
<p> </p>
<p> </p>
<?php do { ?>
<div id="salesresults">
<p><img src="PhotosResults/<?php echo $row_RsSearchForSale3['photo1']; ?>" alt="Photo Property For Sale" class="imageleft" /><span class="pararightloc"><?php echo $row_RsSearchForSale3['loc']; ?></span><span class="price"><?php echo $row_RsSearchForSale3['trueprice']; ?> €</span></p>
<div id="topborder">
<p><span class="location"><?php echo $row_RsSearchForSale3['style']; ?></span><span class="lineheight"><?php echo $row_RsSearchForSale3['number']; ?> Beds</span> <span class="space"><?php echo $row_RsSearchForSale3['bathrooms']; ?>Baths </span></p>
</div>
<p> </p>
<p>Ref : <?php echo $row_RsSearchForSale3['propid']; ?></p>
<p> </p>
<p><?php echo $row_RsSearchForSale3['desc']; ?></p>
<p> </p>
<p> </p>
<p><span class="space"><a href="detailsForSale.php?propid=<?php echo $row_RsSearchForSale3['propid']; ?>" class="moreinfo">More Info</a></span> </p>
<p> </p>
</div>
<?php } while ($row_RsSearchForSale3 = mysql_fetch_assoc($RsSearchForSale3)); ?><p>
<div id="navigate">
<span class="records">Page Navigation</span>
<table border="0" class="centralise">
<tr>
<td><?php if ($pageNum_RsSearchForSale3 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale3=%d%s", $currentPage, 0, $queryString_RsSearchForSale3); ?>">First</a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_RsSearchForSale3 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale3=%d%s", $currentPage, max(0, $pageNum_RsSearchForSale3 - 1), $queryString_RsSearchForSale3); ?>">Previous</a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_RsSearchForSale3 < $totalPages_RsSearchForSale3) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale3=%d%s", $currentPage, min($totalPages_RsSearchForSale3, $pageNum_RsSearchForSale3 + 1), $queryString_RsSearchForSale3); ?>">Next</a>
<?php } // Show if not last page ?> </td>
<td><?php if ($pageNum_RsSearchForSale3 < $totalPages_RsSearchForSale3) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale3=%d%s", $currentPage, $totalPages_RsSearchForSale3, $queryString_RsSearchForSale3); ?>">Last</a>
<?php } // Show if not last page ?> </td>
</tr>
</table>
</div>
<?php } // End RS3 Show if recordset not empty ?>
<?php elseif ($totalRows_RsSearchForSale4 > 0 ) { // Show if recordset not empty ?>
<p class="records">SEARCH RESULTS</p>
<p class="records">Found <?php echo $totalRows_RsSearchForSale4 ?></p>
<p class="Propertiesright">Properties <?php echo ($startRow_RsSearchForSale4 + 1) ?> to <?php echo min($startRow_RsSearchForSale4 + $maxRows_RsSearchForSale4, $totalRows_RsSearchForSale4) ?></p>
<p> </p>
<p> </p>
<?php do { ?>
<div id="salesresults">
<p><img src="PhotosResults/<?php echo $row_RsSearchForSale4['photo1']; ?>" alt="Photo Property For Sale" class="imageleft" /><span class="pararightloc"><?php echo $row_RsSearchForSale4['loc']; ?></span><span class="price"><?php echo $row_RsSearchForSale4['trueprice']; ?> €</span></p>
<div id="topborder">
<p><span class="location"><?php echo $row_RsSearchForSale4['style']; ?></span><span class="lineheight"><?php echo $row_RsSearchForSale4['number']; ?> Beds</span> <span class="space"><?php echo $row_RsSearchForSale4['bathrooms']; ?>Baths </span></p>
</div>
<p> </p>
<p>Ref : <?php echo $row_RsSearchForSale4['propid']; ?></p>
<p> </p>
<p><?php echo $row_RsSearchForSale4['desc']; ?></p>
<p> </p>
<p> </p>
<p><span class="space"><a href="detailsForSale.php?propid=<?php echo $row_RsSearchForSale4['propid']; ?>" class="moreinfo">More Info</a></span> </p>
<p> </p>
</div>
<?php } while ($row_RsSearchForSale4 = mysql_fetch_assoc($RsSearchForSale4)); ?><p>
<div id="navigate">
<span class="records">Page Navigation</span>
<table border="0" class="centralise">
<tr>
<td><?php if ($pageNum_RsSearchForSale4 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale4=%d%s", $currentPage, 0, $queryString_RsSearchForSale4); ?>">First</a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_RsSearchForSale4 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale4=%d%s", $currentPage, max(0, $pageNum_RsSearchForSale4 - 1), $queryString_RsSearchForSale4); ?>">Previous</a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_RsSearchForSale4 < $totalPages_RsSearchForSale4) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale4=%d%s", $currentPage, min($totalPages_RsSearchForSale4, $pageNum_RsSearchForSale4 + 1), $queryString_RsSearchForSale4); ?>">Next</a>
<?php } // Show if not last page ?> </td>
<td><?php if ($pageNum_RsSearchForSale4 < $totalPages_RsSearchForSale4) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale4=%d%s", $currentPage, $totalPages_RsSearchForSale4, $queryString_RsSearchForSale4); ?>">Last</a>
<?php } // Show if not last page ?> </td>
</tr>
</table>
</div>
<?php } // End RS4 Show if recordset not empty ?>
<?php else (totalRows_RSsearchforsale == 0 || totalRows_RsSearchForSale2 == 0 || totalRows_RsSearchForSale3 == 0 ||totalRows_RsSearchForSale4 == 0 ) { // No results?>
<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 } // End No results ?>
</div>
---------------------------------------------------------
<?php
mysql_free_result($RSsearchforsale);
mysql_free_result($RsSearchForSale2);
mysql_free_result($RsSearchForSale3);
mysql_free_result($RsSearchForSale4);
?>
IF, ELSEIF, ELSE statement - cannot get it to work
Moderator: General Moderators
Re: IF, ELSEIF, ELSE statement - cannot get it to work
Why oh why is it so hard for people to read HOW to post code before posting code? Your post is unreadable as it is. [syntax=php]PASTEHERE[/syntax] is the proper format.
You had several problems.
Line 213 needed closing ?>
Line 251 combine closing bracket with elseif
Line 258 ditto line 251
Line 343 ditto
Line 385 needed else changed to elseif
Rather than repost the full code, I'll let you figure out what to do. The closing bracket needs to be on the same line as the elseif.... so <?php } elseif(condition){ ?> and NOT
<?php } //some comment ?>
<?php elseif(condition) {stuff} ?>
You had several problems.
Line 213 needed closing ?>
Line 251 combine closing bracket with elseif
Line 258 ditto line 251
Line 343 ditto
Line 385 needed else changed to elseif
Rather than repost the full code, I'll let you figure out what to do. The closing bracket needs to be on the same line as the elseif.... so <?php } elseif(condition){ ?> and NOT
<?php } //some comment ?>
<?php elseif(condition) {stuff} ?>
Re: IF, ELSEIF, ELSE statement - cannot get it to work
Hi,
So sorry i did not post the code correctly, will do it correctly in future, thank you for the reply i´m most grateful, i´ll get on with amending the code as per your instructions,
So sorry i did not post the code correctly, will do it correctly in future, thank you for the reply i´m most grateful, i´ll get on with amending the code as per your instructions,
Re: IF, ELSEIF, ELSE statement - cannot get it to work
Hi again,
Sorted the Parse error thanks to you. My results now display. - Just not 100% how i want although nearly there.
My problem now is that i´m still not getting the results that i wanted and the IF, ELSEIF, ELSE statement that i put in was my hope of doing this: Basically i´m trying to distinguish between the number of menus that are selected from the main page, and i´d set up 4 recordset (i have 4 menus) each recordset is to retrieve data where the values posted must meet ALL the criteria of each option selected from the menu. It does this if there are results for all the values whether that be from 1, 2, 3 or 4 menus selected but when say 2 of the values don´t match anything in the database instead of bringing up the final else clause - no results - (cause ALL values not found) its still finding results. I feel sure this is because of my CONDITION check, I´m checking the totalRows for each recordset, please could you suggest another way to go about doing the conditional statement to achieve my desired results. I have re done my code in the correct format, soz again, hope you can help me i´ve been trying to do this myself for weeks but realise i do need some help.
-------------------HTML------------------
---------------------
I do look forward to and appreciate your reply.
Sorted the Parse error thanks to you. My results now display. - Just not 100% how i want although nearly there.
My problem now is that i´m still not getting the results that i wanted and the IF, ELSEIF, ELSE statement that i put in was my hope of doing this: Basically i´m trying to distinguish between the number of menus that are selected from the main page, and i´d set up 4 recordset (i have 4 menus) each recordset is to retrieve data where the values posted must meet ALL the criteria of each option selected from the menu. It does this if there are results for all the values whether that be from 1, 2, 3 or 4 menus selected but when say 2 of the values don´t match anything in the database instead of bringing up the final else clause - no results - (cause ALL values not found) its still finding results. I feel sure this is because of my CONDITION check, I´m checking the totalRows for each recordset, please could you suggest another way to go about doing the conditional statement to achieve my desired results. I have re done my code in the correct format, soz again, hope you can help me i´ve been trying to do this myself for weeks but realise i do need some help.
Code: Select all
<?php require_once('Connections/propertypages.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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_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'];
}
mysql_select_db($database_propertypages, $propertypages);
$query_RSsearchforsale = sprintf("SELECT DISTINCT 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"));
$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;
$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'];
}
mysql_select_db($database_propertypages, $propertypages);
$query_RsSearchForSale2 = sprintf("SELECT DISTINCT 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) 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;
$maxRows_RsSearchForSale3 = 10;
$pageNum_RsSearchForSale3 = 0;
if (isset($_GET['pageNum_RsSearchForSale3'])) {
$pageNum_RsSearchForSale3 = $_GET['pageNum_RsSearchForSale3'];
}
$startRow_RsSearchForSale3 = $pageNum_RsSearchForSale3 * $maxRows_RsSearchForSale3;
$varloc3_RsSearchForSale3 = "mpl";
if (isset($_POST['location'])) {
$varloc3_RsSearchForSale3 = $_POST['location'];
}
$varprice3_RsSearchForSale3 = "p9";
if (isset($_POST['price'])) {
$varprice3_RsSearchForSale3 = $_POST['price'];
}
$vartype3_RsSearchForSale3 = "vil";
if (isset($_POST['type'])) {
$vartype3_RsSearchForSale3 = $_POST['type'];
}
$varbed3_RsSearchForSale3 = "b5";
if (isset($_POST['beds'])) {
$varbed3_RsSearchForSale3 = $_POST['beds'];
}
mysql_select_db($database_propertypages, $propertypages);
$query_RsSearchForSale3 = sprintf("SELECT DISTINCT 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) OR (location=%s AND type=%s) OR (location=%s AND beds=%s) OR ( type=%s AND beds=%s) OR (price=%s AND type=%s) OR (price=%s AND beds=%s) ORDER BY detailstable.trueprice ASC", GetSQLValueString($varloc3_RsSearchForSale3, "text"),GetSQLValueString($varprice3_RsSearchForSale3, "text"),GetSQLValueString($varloc3_RsSearchForSale3, "text"),GetSQLValueString($vartype3_RsSearchForSale3, "text"),GetSQLValueString($varloc3_RsSearchForSale3, "text"),GetSQLValueString($varbed3_RsSearchForSale3, "text"),GetSQLValueString($vartype3_RsSearchForSale3, "text"),GetSQLValueString($varbed3_RsSearchForSale3, "text"),GetSQLValueString($varprice3_RsSearchForSale3, "text"),GetSQLValueString($vartype3_RsSearchForSale3, "text"),GetSQLValueString($varprice3_RsSearchForSale3, "text"),GetSQLValueString($varbed3_RsSearchForSale3, "text"));
$query_limit_RsSearchForSale3 = sprintf("%s LIMIT %d, %d", $query_RsSearchForSale3, $startRow_RsSearchForSale3, $maxRows_RsSearchForSale3);
$RsSearchForSale3 = mysql_query($query_limit_RsSearchForSale3, $propertypages) or die(mysql_error());
$row_RsSearchForSale3 = mysql_fetch_assoc($RsSearchForSale3);
if (isset($_GET['totalRows_RsSearchForSale3'])) {
$totalRows_RsSearchForSale3 = $_GET['totalRows_RsSearchForSale3'];
} else {
$all_RsSearchForSale3 = mysql_query($query_RsSearchForSale3);
$totalRows_RsSearchForSale3 = mysql_num_rows($all_RsSearchForSale3);
}
$totalPages_RsSearchForSale3 = ceil($totalRows_RsSearchForSale3/$maxRows_RsSearchForSale3)-1;
$maxRows_RsSearchForSale4 = 10;
$pageNum_RsSearchForSale4 = 0;
if (isset($_GET['pageNum_RsSearchForSale4'])) {
$pageNum_RsSearchForSale4 = $_GET['pageNum_RsSearchForSale4'];
}
$startRow_RsSearchForSale4 = $pageNum_RsSearchForSale4 * $maxRows_RsSearchForSale4;
$varloc4_RsSearchForSale4 = "mpl";
if (isset($_POST['location'])) {
$varloc4_RsSearchForSale4 = $_POST['location'];
}
$vartype4_RsSearchForSale4 = "vil";
if (isset($_POST['type'])) {
$vartype4_RsSearchForSale4 = $_POST['type'];
}
$varprice4_RsSearchForSale4 = "p9";
if (isset($_POST['price'])) {
$varprice4_RsSearchForSale4 = $_POST['price'];
}
$varbed4_RsSearchForSale4 = "b5";
if (isset($_POST['beds'])) {
$varbed4_RsSearchForSale4 = $_POST['beds'];
}
mysql_select_db($database_propertypages, $propertypages);
$query_RsSearchForSale4 = sprintf("SELECT DISTINCT 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 OR price=%s OR type=%s OR beds=%s ORDER BY detailstable.trueprice ASC", GetSQLValueString($varloc4_RsSearchForSale4, "text"),GetSQLValueString($varprice4_RsSearchForSale4, "text"),GetSQLValueString($vartype4_RsSearchForSale4, "text"),GetSQLValueString($varbed4_RsSearchForSale4, "text"));
$query_limit_RsSearchForSale4 = sprintf("%s LIMIT %d, %d", $query_RsSearchForSale4, $startRow_RsSearchForSale4, $maxRows_RsSearchForSale4);
$RsSearchForSale4 = mysql_query($query_limit_RsSearchForSale4, $propertypages) or die(mysql_error());
$row_RsSearchForSale4 = mysql_fetch_assoc($RsSearchForSale4);
if (isset($_GET['totalRows_RsSearchForSale4'])) {
$totalRows_RsSearchForSale4 = $_GET['totalRows_RsSearchForSale4'];
} else {
$all_RsSearchForSale4 = mysql_query($query_RsSearchForSale4);
$totalRows_RsSearchForSale4 = mysql_num_rows($all_RsSearchForSale4);
}
$totalPages_RsSearchForSale4 = ceil($totalRows_RsSearchForSale4/$maxRows_RsSearchForSale4)-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);Code: Select all
<p> </p>
<div id="mainContent">
<?php if ($totalRows_RSsearchforsale > 0 )
{ // Show if recordset not empty ?>
<p class="records">SEARCH RESULTS</p>
<p class="records">Found <?php echo $totalRows_RSsearchforsale ?></p>
<p class="Propertiesright">Properties <?php echo ($startRow_RSsearchforsale + 1) ?> to <?php echo min($startRow_RSsearchforsale + $maxRows_RSsearchforsale, $totalRows_RSsearchforsale) ?></p>
<p> </p>
<p> </p>
<?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> </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 } 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>
<?php } elseif ($totalRows_RsSearchForSale2 > 0 ) { // Show if recordset not empty ?>
<p class="records">SEARCH RESULTS</p>
<p class="records">Found <?php echo $totalRows_RsSearchForSale2 ?></p>
<p class="Propertiesright">Properties <?php echo ($startRow_RsSearchForSale2 + 1) ?> to <?php echo min($startRow_RsSearchForSale2 + $maxRows_RsSearchForSale2, $totalRows_RsSearchForSale2) ?></p>
<p> </p>
<p> </p>
<?php do { ?>
<div id="salesresults">
<p><img src="PhotosResults/<?php echo $row_RsSearchForSale2['photo1']; ?>" alt="Photo Property For Sale" class="imageleft" /><span class="pararightloc"><?php echo $row_RsSearchForSale2['loc']; ?></span><span class="price"><?php echo $row_RsSearchForSale2['trueprice']; ?> €</span></p>
<div id="topborder">
<p><span class="location"><?php echo $row_RsSearchForSale2['style']; ?></span><span class="lineheight"><?php echo $row_RsSearchForSale2['number']; ?> Beds</span> <span class="space"><?php echo $row_RsSearchForSale2['bathrooms']; ?>Baths </span></p>
</div>
<p> </p>
<p>Ref : <?php echo $row_RsSearchForSale2['propid']; ?></p>
<p> </p>
<p><?php echo $row_RsSearchForSale2['desc']; ?></p>
<p> </p>
<p> </p>
<p><span class="space"><a href="detailsForSale.php?propid=<?php echo $row_RsSearchForSale2['propid']; ?>" class="moreinfo">More Info</a></span> </p>
<p> </p>
</div>
<?php } while ($row_RsSearchForSale2 = mysql_fetch_assoc($RsSearchForSale2)); ?><p>
<div id="navigate">
<span class="records">Page Navigation</span>
<table border="0" class="centralise">
<tr>
<td><?php if ($pageNum_RsSearchForSale2 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale2=%d%s", $currentPage, 0, $queryString_RsSearchForSale2); ?>">First</a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_RsSearchForSale2 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale2=%d%s", $currentPage, max(0, $pageNum_RsSearchForSale2 - 1), $queryString_RsSearchForSale2); ?>">Previous</a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_RsSearchForSale2 < $totalPages_RsSearchForSale2) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale2=%d%s", $currentPage, min($totalPages_RsSearchForSale2, $pageNum_RsSearchForSale2 + 1), $queryString_RsSearchForSale2); ?>">Next</a>
<?php } // Show if not last page ?> </td>
<td><?php if ($pageNum_RsSearchForSale2 < $totalPages_RsSearchForSale2) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale2=%d%s", $currentPage, $totalPages_RsSearchForSale2, $queryString_RsSearchForSale2); ?>">Last</a>
<?php } // Show if not last page ?> </td>
</tr>
</table>
</div>
<?php } elseif ($totalRows_RsSearchForSale3 > 0 ) { // Show if recordset not empty ?>
<p class="records">SEARCH RESULTS</p>
<p class="records">Found <?php echo $totalRows_RsSearchForSale3 ?></p>
<p class="Propertiesright">Properties <?php echo ($startRow_RsSearchForSale3 + 1) ?> to <?php echo min($startRow_RsSearchForSale3 + $maxRows_RsSearchForSale3, $totalRows_RsSearchForSale3) ?></p>
<p> </p>
<p> </p>
<?php do { ?>
<div id="salesresults">
<p><img src="PhotosResults/<?php echo $row_RsSearchForSale3['photo1']; ?>" alt="Photo Property For Sale" class="imageleft" /><span class="pararightloc"><?php echo $row_RsSearchForSale3['loc']; ?></span><span class="price"><?php echo $row_RsSearchForSale3['trueprice']; ?> €</span></p>
<div id="topborder">
<p><span class="location"><?php echo $row_RsSearchForSale3['style']; ?></span><span class="lineheight"><?php echo $row_RsSearchForSale3['number']; ?> Beds</span> <span class="space"><?php echo $row_RsSearchForSale3['bathrooms']; ?>Baths </span></p>
</div>
<p> </p>
<p>Ref : <?php echo $row_RsSearchForSale3['propid']; ?></p>
<p> </p>
<p><?php echo $row_RsSearchForSale3['desc']; ?></p>
<p> </p>
<p> </p>
<p><span class="space"><a href="detailsForSale.php?propid=<?php echo $row_RsSearchForSale3['propid']; ?>" class="moreinfo">More Info</a></span> </p>
<p> </p>
</div>
<?php } while ($row_RsSearchForSale3 = mysql_fetch_assoc($RsSearchForSale3)); ?><p>
<div id="navigate">
<span class="records">Page Navigation</span>
<table border="0" class="centralise">
<tr>
<td><?php if ($pageNum_RsSearchForSale3 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale3=%d%s", $currentPage, 0, $queryString_RsSearchForSale3); ?>">First</a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_RsSearchForSale3 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale3=%d%s", $currentPage, max(0, $pageNum_RsSearchForSale3 - 1), $queryString_RsSearchForSale3); ?>">Previous</a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_RsSearchForSale3 < $totalPages_RsSearchForSale3) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale3=%d%s", $currentPage, min($totalPages_RsSearchForSale3, $pageNum_RsSearchForSale3 + 1), $queryString_RsSearchForSale3); ?>">Next</a>
<?php } // Show if not last page ?> </td>
<td><?php if ($pageNum_RsSearchForSale3 < $totalPages_RsSearchForSale3) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale3=%d%s", $currentPage, $totalPages_RsSearchForSale3, $queryString_RsSearchForSale3); ?>">Last</a>
<?php } // Show if not last page ?> </td>
</tr>
</table>
</div>
<?php } elseif ($totalRows_RsSearchForSale4 > 0 ) { // Show if recordset not empty ?>
<p class="records">SEARCH RESULTS</p>
<p class="records">Found <?php echo $totalRows_RsSearchForSale4 ?></p>
<p class="Propertiesright">Properties <?php echo ($startRow_RsSearchForSale4 + 1) ?> to <?php echo min($startRow_RsSearchForSale4 + $maxRows_RsSearchForSale4, $totalRows_RsSearchForSale4) ?></p>
<p> </p>
<p> </p>
<?php do { ?>
<div id="salesresults">
<p><img src="PhotosResults/<?php echo $row_RsSearchForSale4['photo1']; ?>" alt="Photo Property For Sale" class="imageleft" /><span class="pararightloc"><?php echo $row_RsSearchForSale4['loc']; ?></span><span class="price"><?php echo $row_RsSearchForSale4['trueprice']; ?> €</span></p>
<div id="topborder">
<p><span class="location"><?php echo $row_RsSearchForSale4['style']; ?></span><span class="lineheight"><?php echo $row_RsSearchForSale4['number']; ?> Beds</span> <span class="space"><?php echo $row_RsSearchForSale4['bathrooms']; ?>Baths </span></p>
</div>
<p> </p>
<p>Ref : <?php echo $row_RsSearchForSale4['propid']; ?></p>
<p> </p>
<p><?php echo $row_RsSearchForSale4['desc']; ?></p>
<p> </p>
<p> </p>
<p><span class="space"><a href="detailsForSale.php?propid=<?php echo $row_RsSearchForSale4['propid']; ?>" class="moreinfo">More Info</a></span> </p>
<p> </p>
</div>
<?php } while ($row_RsSearchForSale4 = mysql_fetch_assoc($RsSearchForSale4)); ?><p>
<div id="navigate">
<span class="records">Page Navigation</span>
<table border="0" class="centralise">
<tr>
<td><?php if ($pageNum_RsSearchForSale4 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale4=%d%s", $currentPage, 0, $queryString_RsSearchForSale4); ?>">First</a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_RsSearchForSale4 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale4=%d%s", $currentPage, max(0, $pageNum_RsSearchForSale4 - 1), $queryString_RsSearchForSale4); ?>">Previous</a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_RsSearchForSale4 < $totalPages_RsSearchForSale4) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale4=%d%s", $currentPage, min($totalPages_RsSearchForSale4, $pageNum_RsSearchForSale4 + 1), $queryString_RsSearchForSale4); ?>">Next</a>
<?php } // Show if not last page ?> </td>
<td><?php if ($pageNum_RsSearchForSale4 < $totalPages_RsSearchForSale4) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_RsSearchForSale4=%d%s", $currentPage, $totalPages_RsSearchForSale4, $queryString_RsSearchForSale4); ?>">Last</a>
<?php } // Show if not last page ?> </td>
</tr>
</table>
</div>
<?php } elseif (totalRows_RSsearchforsale == 0 || totalRows_RsSearchForSale2 == 0 || totalRows_RsSearchForSale3 == 0 ||totalRows_RsSearchForSale4 == 0 ) { // No results?>
<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 } // End No results ?>
</div>
Code: Select all
<?php
mysql_free_result($RSsearchforsale);
mysql_free_result($RsSearchForSale2);
mysql_free_result($RsSearchForSale3);
mysql_free_result($RsSearchForSale4);
?>