My search query ; not specific enough!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cap2cap10
Forum Contributor
Posts: 158
Joined: Mon Apr 14, 2008 11:06 pm

My search query ; not specific enough!

Post 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
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: My search query ; not specific enough!

Post 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)?
Post Reply