** solved ***Search using selection items

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

** solved ***Search using selection items

Post by mhouldridge »

Hi,

I am trying to carry out a search using selection items put into an array. I am not sure that this is the best way to do this, however I think it could work.

I have the following code;

Code: Select all

$array [0]= $location;
$array [1]=$bedrooms;
$array [2]=$type;
$array [3]=$price;

echo $array[0];

// Query database with search variables	
$result = mysql_query("SELECT * FROM homes WHERE location LIKE '%$array[0]%'");
Please help.
Last edited by mhouldridge on Mon Nov 28, 2005 2:13 pm, edited 1 time in total.
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

Here is my query... It doesnt seem to give me a result from my selection boxes;

Code: Select all

$result = mysql_query("SELECT * FROM location, bedrooms, type, price WHERE location = '$array[0]' AND bedrooms = '$array[1]' AND type='$array[2]' AND price '$array[3]'");
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

got it working now.
Post Reply