Im a complete newbie!
Im building a real estate site and having trouble with the price range drop down menu. I am using a search page and a results page(Both HTML). I am using Dreamweaver's advanced recordset box. The trouble seems to be(if not my complete ignorance) every time I add a variable, the other values move, change names, or completely disappear.
This thread is what I'm trying to do:
http://www.phpbuilder.com/board/showthread.php?t=10287567&highlight=price+range
I have stared at this for 2 days with no luck. Atttached is my code.
<?php require_once('Connections/connBelle.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;
$maxRows_belleResults = 10;
$pageNum_belleResults = 0;
if (isset($_GET['pageNum_belleResults'])) {
$pageNum_belleResults = $_GET['pageNum_belleResults'];
}
$startRow_belleResults = $pageNum_belleResults * $maxRows_belleResults;
$colname_belleResults = "-1";
if (isset($_GET['baths'])) {
$colname_belleResults = $_GET['baths'];
}
$varBeds_belleResults = "-1";
if (isset($_GET['beds'])) {
$varBeds_belleResults = $_GET['beds'];
}
$varPrice_belleResults = $_GET['ListPrice'];
switch($varPrice) {
case "any":
$range = "";
break;
case "0":
$range = " AND (price >= 0) AND (price <= 50000)";
break;
case "1":
$range = " AND (price > 50000) AND (price <= 150000)";
break;
case "2":
$range = " AND (price > 150000) AND (price <= 200000)";
break;
case "3":
$range = " AND (price > 200000) AND (price <= 250000)";
break;
case "4":
$range = " AND (price > 300000) AND (price <= 400000)";
break;
default:
$range = "";
}
mysql_select_db($database_connBelle, $connBelle);
$query_belleResults = sprintf("SELECT BathsTotal, Beds, ListPrice, Remarks FROM Condos WHERE BathsTotal = %s AND Beds = %s AND ListPrice %s ORDER BY ListPrice DESC", GetSQLValueString($colname_belleResults, "int"),GetSQLValueString($varBeds_belleResults, "int"),GetSQLValueString($varPrice_belleResults, "int"));
$query_limit_belleResults = sprintf("%s LIMIT %d, %d", $query_belleResults, $startRow_belleResults, $maxRows_belleResults);
$belleResults = mysql_query($query_limit_belleResults, $connBelle) or die(mysql_error());
$row_belleResults = mysql_fetch_assoc($belleResults);
if (isset($_GET['totalRows_belleResults'])) {
$totalRows_belleResults = $_GET['totalRows_belleResults'];
} else {
$all_belleResults = mysql_query($query_belleResults);
$totalRows_belleResults = mysql_num_rows($all_belleResults);
}
$totalPages_belleResults = ceil($totalRows_belleResults/$maxRows_belleResults)-1;
?>
<?php do { ?>
<tr>
<td><?php echo $row_belleResults['BathsTotal']; ?></td>
<td><?php echo $row_belleResults['Beds']; ?></td>
<td><?php echo $row_belleResults['ListPrice']; ?></td>
<td><?php echo $row_belleResults['Remarks']; ?></td>
</tr>
<?php } while ($row_belleResults = mysql_fetch_assoc($belleResults)); ?>
</table>
I apologize in advance if this does not post in the forum PHP format.
-Thanks, Jake