Page 1 of 1

Mysql search query!

Posted: Sun Feb 08, 2009 7:52 am
by cap2cap10
Greetings php technorati, I am working on a specific query that seaches out specific criteria listed in my database. The data that is being queried exists in two tables of the same database and I need it to return data even if all of the query input is not met. let me know if I am on the right track. Here is the code query:

Code: Select all

$query = "SELECT category, degree, years_exp, work_time, available, image_name FROM js_db1
INNER JOIN js_db2 ON js_db2.candidateID = js_db1.candidateID WHERE category = '$category'
&& degree = '$degree' && years_exp = '$years_exp' && work_time = '$work_time' && available = '$available'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
    {$row['candidateID']}.
    {$row['category']} .
    {$row['degree']} ;
    {$row['years_exp']}
    {$row['work_time']}
    {$row['available']}
    {$row['image_name']}
}
 
note: image_name is in the second table

Search results will be echoed on the same page! Anyone have any input? No pun intended.

Thanks in advance!


Batoe :drunk:

Re: Mysql search query!

Posted: Sun Feb 08, 2009 9:57 am
by jayshields
I take it you have tried what you've got. What happens? What would you like to happen?

Re: Mysql search query!

Posted: Sun Feb 08, 2009 11:02 am
by cap2cap10
I haven't actually attempted to test the code. I just wanted to know if anyone sees any errors in syntax. I am still a novice.

Batoe

Re: Mysql search query!

Posted: Sun Feb 08, 2009 11:17 am
by jayshields
Well one thing that jumps out at me is && instead of AND in your query. Just test it and mysql_error() will tell you what's wrong with it.