Need help with PHP/MySQL drop down menu


Posted on 16th Feb 2014 07:03 pm by admin

I need help on how I can implement a drop down menu which queries mysql database and output the available data based on price range. This feature has been used here http://www.vebra.com - I will appreciate your help.

$searchSQL = "SELECT * FROM simple_search WHERE";

Did you know?Explore Trending and Topic pages for more stories like this.

// grab the search types.
$types = array();
$types[] = isset($_GET['price'])?"`price` LIKE '%{$searchTermDB}%'":'';
$types[] = isset($_GET['location'])?"`location` LIKE '%{$searchTermDB}%'":'';

$types = array_filter($types, "removeEmpty"); // removes any item that was empty (not checked)

if (count($types) < 1)
$types[] = "`id` LIKE '%{$searchTermDB}%'"; // use the estate as a default search if none are checked


$andOr = isset($_GET['matchall'])?'AND':'OR';
$searchSQL .= implode(" {$andOr} ", $types) . " ORDER BY `price`"; // order by price.

$searchResult = mysql_query($searchSQL) or die("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}");

if (mysql_num_rows($searchResult) < 1) {
$error[] = "The search term provided <i>{$searchTerms}</i> yielded no results.";
}else {

$results = array(); // the result array
$i = 1;
while ($row = mysql_fetch_assoc($searchResult)) {
$results[] = "{$row['location']} <br/>{$row['image']}<br/>{$row['price']}";

$i++;
No comments posted yet

Your Answer:

Login to answer
120 Like 36 Dislike
Previous forums Next forums
Other forums

Convert Binary String to Decimal
Trying to Get:
Decimal: 305419896

Out of:
Binary String: xV4

Seperate team from score
I am writing a site that does a NFL Pick 'em type application and I have a feed that gives me the sc

1,000 select boxes with 100 options?!
I have 1 drop down select box with 1,000 options.


In some case, there will be 100+ of the

Grids not displaying decimals, and behaving differently on different PCs?
Hello,

I coded a relatively simple MII application that allows data from a form to be add

Why is this query failing?
Why is this not working?
$query = "SELECT * FROM `users` WHERE `userid` = " . $USERID

Encrypt php code?
Is it possible to encrypt php code in files,
so that it displays a load of unreadable characters

Retrieving Data from Two Different Databases
Hello All,

Ran into another problem and would appreciate some help! I have two datab

PHP Form to Variable.
Hi! I have written a HTML-form code in DreamWeaver CS3 (in a PHP doc) and I really need it to work s

post to self
Trying to get my form to submit to itself. However I am also trying to use an image for my submit bu

Linked Keywords
I am trying to get a script that makes my predefined keyword converted to links and / or converted t

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash