PDA

View Full Version : passing value range via form post



bikeman
12-05-2008, 09:49 AM
HI

I want to pass a price range from one page to another via a form post, and then filter some mysql db records based upon this range.

I can pass a single value and filter everything upto this value but what I really want is to filter on a min-max range of values. Here's what I have so far:

input page:

<form action="propertylist.php" method="post" name="frm_forsale" id="frm_forsale">

<p><a href="propertylist.php?offeredfor=1">
<p>what is your price range? </p>
<p>
<select name="priceband" id="priceband">
<option value="250000">up to &pound;250,000</option>
<option value="500000">&pound;250K to &pound;500K</option>
<option value="500001">over &pound;500,000</option>
</select>
<input type="submit" name="go" value="Go" />
</p>
</form>

target page:

mysql_select_db($database_estateagent, $estateagent);

switch($colname_rs_property)
{
case "250000";
$query_rs_property = "SELECT * FROM propertydata WHERE price < 249999 ORDER BY price ASC";
break;
case "500000";
$query_rs_property = "SELECT * FROM propertydata WHERE price > 249999 AND <499999 ORDER BY price ASC";
break;
default;
$query_rs_property = "SELECT * FROM propertydata WHERE price > 499999 ORDER BY price ASC";
break;
}

Thanks

bikeman
12-05-2008, 09:50 AM
oops fixed it -
price > 249999 AND <499999
should have been
price > 249999 AND price < 499999