Log in

View Full Version : How to use both url and post variables on same target page



bikeman
12-05-2008, 09:55 AM
HI
I need to target page to filter data based upon either the received url variable OR the received form post variable.

I have two seperate bits of code which both work independently, ut when they are both use neither wokrs. How do I combine them? Thanks

filter by received url:
mysql_select_db($database_estateagent, $estateagent);

switch($colname_rs_property)
{
case "1"; /* properties for sale */
$query_rs_property = sprintf("SELECT * FROM propertydata WHERE offeredfor = 1 ORDER BY price ASC", $colname_rs_property);/*code for filtered list dep upon received url*/
break;
case "2"; /* properties for rent */
$query_rs_property = sprintf("SELECT * FROM propertydata WHERE offeredfor = 2 ORDER BY price ASC", $colname_rs_property);/*code for filtered list dep upon received url*/
break;
default; /* all properties */
$query_rs_property = sprintf("SELECT * FROM propertydata ORDER BY price ASC", $colname_rs_property); /*code for all properties*/
break;
}

$query_limit_rs_property = sprintf("%s LIMIT %d, %d", $query_rs_property, $startRow_rs_property, $maxRows_rs_property);
$rs_property = mysql_query($query_limit_rs_property, $estateagent) or die(mysql_error());
$row_rs_property = mysql_fetch_assoc($rs_property);

filter on post variable:
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 price < 499999 ORDER BY price ASC";
break;
default;
$query_rs_property = "SELECT * FROM propertydata WHERE price > 499999 ORDER BY price ASC";
break;
}

$rs_property = mysql_query($query_rs_property, $estateagent) or die(mysql_error());
$row_rs_property = mysql_fetch_assoc($rs_property);
$totalRows_rs_property = mysql_num_rows($rs_property);

gpigate
12-05-2008, 04:45 PM
could you set the _GET var or url var as a hidden element and then pass it along as a _POST when the form is submitted?