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";


// 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

Help with parsing this html
Hi,
I've got some html i just need a couple of strings from.. argh, it's freaking me out. I've t

building a function with multiple outputs
I want to build a function that has multiple outputs.

I know but am not to sure how I should

PRotect my POST DATA... FROM HTML ATTACKS
I need to like let's say

If a user submit's his Prayer and he put's <meta refresh stuf

SQl num_rows problem
when i try to count rows from an SQL select i get an warning

Code: [Select]$countviews = mysq

PHP code needed to get/post form fields and request mysql query results.
I'm new to PHP

I've created an html form to allow the user to request a basic telephone dire

How to clone an SAP ECC using bacup tape on z/os?
We want to clone our production to a different SID using backup tape.

How to give the privillege for triggers?
Hi,

How to give the privillage for triggers to particular user?

Please let me

PHP Programming error. Please help!
Hi there,

Am making a website for a friend and have encountered a problem that i need fixing

Losing 'page' data
I have this code that allows me to update my database. But after updating, I lose the $_GET['page']

Access website from only 1 computer...?
One of my customers wants his website to only be accessed by people in which they bought the website

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