Jump to content

What is wrong with this statement ?????


only1perky

Recommended Posts

Hi Guys I going mad here as I can't get my advanced search working and I don't know why.

 

At the moment I have a search page with a text box and select option and some checkboxes.

 

If I just use the text box and checkboxes it works fine.

However when I use the select box and checkboxes it ignores my sql. Here is my code:

 

if($_GET['criteria'] != "" && $_GET['area'] != "") {

mysql_select_db($database_connuser, $connuser) or die;
$find3 = $_GET['area'];
$find = implode("=1 AND ",$_GET['criteria'])."=1";
$query = "select * from table where area like \"%$find3%\" AND ".$find." order by featured desc, venue asc";

 

Now when I echo the query it completely ignores the first area and goes straight to the checkbox criteria.

 

I know $_GET['area'] is being passed as when I simply search by area alone it works fine.

What am I doing wrong?

Link to comment
Share on other sites

Hi,

 

Try this

<?php
$query = "SELECT * FROM table WHERE area LIKE \"%$find3%\" AND area LIKE ".$find." ORDER BY featured DESC, venue ASC";
?>

 

You had not added a field to compare $find to. I also recommend using UPPERCASE for standard SQL words for ease of reading.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.