Hi guys, well as the thread title says, i've made a search engine for a property site that uses a form to specify what to search (ie. property status, type, location, bedrooms, price). And outputs as a table.

The problem is i don't know how to make the function return the results that i've specifically searched for, currently my php coding goes like this:

// form variables
if (isset($_POST)) {$status = $_POST; } else { $status = ""; }
if (isset($_POST)) {$prop_type = $_POST; } else { $prop_type = ""; }
if (isset($_POST)) {$location = $_POST; } else { $location = ""; }
if (isset($_POST)) {$bedrooms = $_POST; } else { $bedrooms = ""; }
if (isset($_POST)) {$min_price = $_POST; } else { $min_price = ""; }
if (isset($_POST)) {$max_price = $_POST; } else { $max_price = ""; }

mysql_select_db($database, $dbconnect);
$query_dosearch = "SELECT * FROM ".$sitename."_properties WHERE status = '$status' OR property_type = '$prop_type' OR location = '$location' OR num_bedrooms = '$bedrooms' OR price BETWEEN '$min_price' AND '$max_price' ";
$dosearch = mysql_query($query_dosearch, $dbconnect) or die(mysql_error($dbconnect));
$row_dosearch = mysql_fetch_assoc($dosearch);
$totalRows_dosearch = mysql_num_rows($dosearch);


I've tried using AND but that returns no results, so can anyone help me?

9 Years
Discussion Span
Last Post by w_3rabi

As far as I know, there is no need of :

mysql_query($query_dosearch, $dbconnect)
You can simply do

Also I do not see a function mysql_connect() or mysql_pconnect() which connects to the database? Have you forgotten that ?


man echo the sql syntax
sometimes there is errors u cant c until u echo the sql
it is a good habit

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.