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
cap2cap10
Forum Contributor
Posts: 158 Joined: Mon Apr 14, 2008 11:06 pm
Post
by cap2cap10 » Sun Feb 08, 2009 7:52 am
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
jayshields
DevNet Resident
Posts: 1912 Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England
Post
by jayshields » Sun Feb 08, 2009 9:57 am
I take it you have tried what you've got. What happens? What would you like to happen?
cap2cap10
Forum Contributor
Posts: 158 Joined: Mon Apr 14, 2008 11:06 pm
Post
by cap2cap10 » Sun Feb 08, 2009 11:02 am
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
jayshields
DevNet Resident
Posts: 1912 Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England
Post
by jayshields » Sun Feb 08, 2009 11:17 am
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.