We have a HTML search page, having multiple text fields to search.
The user can input as many values as he want in text field and on submit, the query should return appropriate results.
We have different tables as
$query = array();
$query = "candidate.cand_desc = '".mysql_real_escape_string($_POST['keyword_s_dec'])."'";
$join.="JOIN candidate_contact ON candidate.cand_desc=candidate_contact.cand_id";
//$join.="select * from candidate join candidate_contact ON candidate.cand_number=candidate_contact.cand_id WHERE candidate.cand_desc='".$_POST['keyword_s_dec']."'";
$query = "candidate_contact.cand_location = '".mysql_real_escape_string($_POST['keyword_s_location;'])."'";///edit
$join.=" AND JOIN candidate_contact ON candidate.cand_number=candidate_contact.cand_id";
//$condition = implode(' AND ', $query);
$condition = implode(' AND ', $query);
$sql = "SELECT * FROM candidate".$join.' where '.$condition;
where - candidate is my main table and candidate_contact is another table.
where -cand_desc is database column in candidate & keyword_s-dec is text field id.
where- cand_location is my database column in candidate_contact and keywors_s_location is text field id.
This code is being slightly guided by one of stack overflow member and we though this should be edit to get more precised to the problem.
SELECT candidate.*,candidate_contact.feild_name1,candidate_contact.feild_name2 FROM candidate LEFT JOIN candidate_contact ON candidate.cand_number=candidate_contact.cand_id where $condition
Note:- add the table name with .(dot)in the where clause to define which feild name you want to do the comparision as shown in selection field area of the query and can continue joinning different tables in the same way as above before the where clause.
Hope this will solve your problem