PHP search facility help?

  • Thread starter Thread starter mel
  • Start date Start date
M

mel

Guest
I am trying to make a simple search facility that allows the user to select from two drop down boxes to search the database. I want to be able to search for number of rooms and area for example all houses with 4 bedrooms in high street.

this is the code i have at the moment which can search for one thing and i cannot seem to get it to look for two.

searchresults.php


<?php
$search=$_POST["search"];

//get the mysql and store them in $result
//change whatevertable to the mysql table you're using
//change whatevercolumn to the column in the table you want to search
$result = mysql_query("SELECT * FROM tbl_house WHERE area LIKE '%$search%'");

//grab all the content
while($r=mysql_fetch_array($result))
{
//the format is $variable = $r["nameofmysqlcolumn"];
//modify these to match your mysql table columns

$area=$r["area"];
$house_name=$r["house_name"];
$number_of_rooms=$r["number_of_rooms"];
$price=$r["price"];
$deposit=$r["deposit"];
$Description=$r["Description"];
$kitchen=$r["kitchen"];
$bathroom=$r["bathroom"];
$bedroom=$r["bedroom"];
$lounge=$r["lounge"];

$house_id=$r["house_id"];

//display the row
echo "$house_name <br> $area <br> $number_of_rooms <br> $price | $deposit <br>";
}
?>


index.php form

Search:

<form method="post" action="searchresults.php">



<select name="search">
<option value="High Street">High Street</option>
<option value="West End">West End</option>


</select><br />
<input type="Submit" name="Submit" value="Submit">
</form>
 
Back
Top