php - Query for searching multiple user inputs in HTML text field for multiple tables -


we have html search page, having multiple text fields search.

the user can input many values want in text field , on submit, query should return appropriate results.

we have different tables as

  • candidate
  • candidate_contact
  • company
  • etc.

example:

user enters candidate should have java skills lives in california should not have experience less 2 years.

these records can in same or different tables (like skills , country in same table , exp in table)

its including , excluding search result.

$query = array(); if (!empty($_post['keyword_s_dec']))  {  $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 * candidate join candidate_contact on candidate.cand_number=candidate_contact.cand_id candidate.cand_desc='".$_post['keyword_s_dec']."'";  }  if (!empty($_pot['keyword_s_location']))   {   $query[] = "candidate_contact.cand_location = '".mysql_real_escape_string($_post['keyword_s_location;'])."'";///edit   $join.=" , join candidate_contact on candidate.cand_number=candidate_contact.cand_id";  }   //$condition = implode(' , ', $query); $condition = implode(' , ', $query); $sql = "select * candidate".$join.' '.$condition;  - candidate main table , candidate_contact table. -cand_desc database column in candidate & keyword_s-dec text field id. where- cand_location database column in candidate_contact , keywors_s_location text field id.  code being guided 1 of stack overflow member , though should edit more precised problem. 

select candidate.*,candidate_contact.feild_name1,candidate_contact.feild_name2 candidate  left join candidate_contact   on candidate.cand_number=candidate_contact.cand_id $condition 

note:- add table name .(dot)in clause define feild name want comparision shown in selection field area of query , can continue joinning different tables in same way above before clause.

hope solve problem


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -