Page 1 of 1

Re: search form with select and option values

Posted: Sat Oct 11, 2014 8:32 pm
by Celauran
You need something to tie the clauses together. Currently, you've got something like

Code: Select all

SELECT * FROM privatelistings WHERE make LIKE '%Acura%' OR model LIKE '%ILX%' Price BETWEEN 10.00 AND 20.00
whereas you want something like

Code: Select all

SELECT * FROM privatelistings WHERE (make LIKE '%Acura%' OR model LIKE '%ILX%') AND Price BETWEEN 10.00 AND 20.00

Re: search form with select and option values

Posted: Sun Oct 12, 2014 8:23 am
by Celauran
You're appending $price to your query before having defined it.

Re: search form with select and option values

Posted: Sun Oct 12, 2014 1:40 pm
by Celauran

Code: Select all

  case 1  :  $price = " Price BETWEEN £10 AND £20 ";  break; 
What's going on here? How is price stored in your DB?

Code: Select all

AND price
That's not going to work. 'price' is a string literal.

What is the value of $query after you submit the form?

Re: search form with select and option values

Posted: Sun Oct 12, 2014 2:10 pm
by Celauran
The fact that you have a hanging AND is going to cause problems for sure. I'd also advise against storing the prices that way; numeric values is a better idea and you can prepend the currency symbol on output. The way you've got things structured is also potentially problematic; your query is only defined if $where_clause contains values, which is fine, but you're trying to execute the query regardless. Finally, what happens if price isn't defined?