Page 1 of 1

My search query ; not specific enough!

Posted: Thu Apr 09, 2009 12:21 pm
by cap2cap10
Greetings php technorati! Ok, my search query works but it will not return a specific entry. I used the AND with the variables and recieved no entries found. Even though there were entries that match my search criteria. :banghead:
here is the code:

Code: Select all

$query = "SELECT * FROM js_profile WHERE category ='$category' AND years_exp = '$years_exp' AND
    degree ='$degree' AND work_time ='$work_time' AND available ='$available' LIMIT 0, 2000 ";
    $result = mysql_query($query) or die(mysql_error());

Code: Select all

$query = "SELECT * FROM js_profile WHERE category ='$category' AND years_exp = '$years_exp' OR
    degree ='$degree' OR work_time ='$work_time' OR available ='$available' LIMIT 0, 2000 ";
    $result = mysql_query($query) or die(mysql_error());
What do i need to do to get very specific user defined search results from the database?

thanks in advance,

Batoe

Re: My search query ; not specific enough!

Posted: Thu Apr 09, 2009 12:54 pm
by jayshields
Have you output $query after building it to make sure it contains what you think?
Have you executed an example query in phpMyAdmin?
Have you tried using brackets around your WHERE clause expressions (especially when mixing AND with OR - it gets confusing)?