User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 402,741 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,467 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 512 | Replies: 2
Reply
Join Date: Mar 2007
Posts: 5
Reputation: JSR is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
JSR JSR is offline Offline
Newbie Poster

Property Search Engine

  #1  
Jun 5th, 2007
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:
<?php
// form variables
if (isset($_POST['prop_status'])) {$status = $_POST['prop_status']; } else { $status = ""; }
if (isset($_POST['prop_type'])) {$prop_type = $_POST['prop_type']; } else { $prop_type = ""; }
if (isset($_POST['location'])) {$location = $_POST['location']; } else { $location = ""; }
if (isset($_POST['bedrooms'])) {$bedrooms = $_POST['bedrooms']; } else { $bedrooms = ""; }
if (isset($_POST['min_price'])) {$min_price = $_POST['min_price']; } else { $min_price = ""; }
if (isset($_POST['max_price'])) {$max_price = $_POST['max_price']; } 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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2007
Posts: 41
Reputation: hussulinux is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
hussulinux hussulinux is offline Offline
Light Poster

Re: Property Search Engine

  #2  
Jun 7th, 2007
As far as I know, there is no need of :

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

Also I do not see a function mysql_connect() or mysql_pconnect() which connects to the database? Have you forgotten that ?
Reply With Quote  
Join Date: Dec 2006
Location: syria
Posts: 157
Reputation: w_3rabi is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 8
w_3rabi's Avatar
w_3rabi w_3rabi is offline Offline
Junior Poster

Re: Property Search Engine

  #3  
Jun 7th, 2007
man echo the sql syntax
sometimes there is errors u cant c until u echo the sql
it is a good habit
programming is an art ,only for those who can understand it.
- th3 php wr3nch -
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 7:45 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC