Jump to content

Web Design help


JaMoUsE
 Share

Recommended Posts

One for the it boffins! cough Ant (help please!)

 

Im creating an estate agents website as part of my uni course and it obviously needs a search feature.

 

Im using HTML and have a small SQL database,

 

Basically I have 5 or 6 locations and they work fine from the drop down menu, however i want an option that will return all locations.

 

For example i have

 

<select name = "city" id = "city">

<option value="Newcastle">Newcastle City Centre</option>

<option value="Gosforth">Gosforth</option>

<option value="Jesmond">Jesmond</option>

<option value="Gateshead">Gateshead</option>

<option value="Heaton">Heaton</option>

<option value=" ">All Locations </option>

</select>

 

Is there a way you can select all the options? as no matter what i try i cant seem to get it to work?

 

 

My SQL statement is this

 

$type= $_REQUEST ["type"];

$city= $_REQUEST ["city"];

$nobedrooms= $_REQUEST ["nobedrooms"];

$price= $_REQUEST ["price"];

$typeselect=("SELECT * FROM property WHERE type LIKE'$type' AND city LIKE'$city' AND nobedrooms ='$nobedrooms'");

//

execute sql statement

$rstype

= mysql_query($typeselect);

//

construct sql statement

Thanks in advance

Edited by JaMoUsE
Link to comment
Share on other sites

Like so...

 

$type= $_REQUEST ["type"];

$city= $_REQUEST ["city"];

$nobedrooms= $_REQUEST ["nobedrooms"];

$price= $_REQUEST ["price"];

 

if($city == ' ' ){$where = " AND city LIKE '$city' ";}else{$where ='';}

$typeselect=("SELECT * FROM property WHERE type LIKE'$type' $where AND nobedrooms ='$nobedrooms'");

 

Edited by Ruler of Planet Houston
Link to comment
Share on other sites

Like so...

 

$type= $_REQUEST ["type"];

$city= $_REQUEST ["city"];

$nobedrooms= $_REQUEST ["nobedrooms"];

$price= $_REQUEST ["price"];

 

if($city == ' ' ){$where = " AND city LIKE '$city' ";}else{$where ='';}

$typeselect=("SELECT * FROM property WHERE type LIKE'$type' $where AND nobedrooms ='$nobedrooms'");

 

 

This code does return all locations but even if I select a specific location it still returns all locations

Edited by JaMoUsE
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.