Not sure is this is a PHP or MYSQL question..
I have a website and am trying to make a search function. Example would be to search by minimum price, maximum price, minimum square feet, area of town, etc...
All of the fields are optional also, so if they leave them blank the search needs to reflect that.
I'm fluent in PHP but am running into a brickwall with this one, this is the direction I'm going in, can someone tell me what I'm doing wrong?? *pseudo code...
if($search_minprice != ''){
$result = mysql_query("SELECT id FROM listing WHERE price >= '$search_minprice' ORDER BY id ASC ");
$row = mysql_fetch_array($result);
foreach ($row as &$value) {
if($search_livsqft != ''){
$result2 = mysql_query("SELECT * FROM listing WHERE id = '$value' AND livsqft >= '$search_livsqft ORDER BY id ASC ");
while($row2 = mysql_fetch_array($result2)){
$street= $row2['street'];
echo $street."<br>";
}}
}}
I'm not too familar with foreach but it seems the way to go for this, I've always been able to avoid using foreach to my own detriment...
Any help would be appreciated, thanks!