mysql - PHP Search Engine -
i have put complicated search form. using arrays have managed searching checkboxes.
if(isset($_post['search']) && !empty($_post['search'])){ foreach($_post['search'] $key=>$value){ if($value==1) $search[] = "$key"; } $searchstring = implode(' , ', $search);
}
$query = "select candidate_id.master_id, candidate_contact_details.first_name, candidate_contact_details.last_name, candidate_contact_details.home_phone, candidate_contact_details.work_phone, candidate_contact_details.mobile_phone, candidate_contact_details.email candidate_id, candidate_contact_details, qualifications, security_experience, previous_career qualifications.active = 'finished' , candidate_id.master_id = candidate_contact_details.c_id , candidate_id.master_id = qualifications.c_id , $searchstring";
i know how searches of database specific term. ie. postcode field know how can add query? know how either checkbox based searches or text field based searches cannot figue out how combine two.
thanks again jason
as far can understand question, need map names of form fields database columns. set array like:
$post_map = array( 'home_phone' => 'candidate_contact_details.home_phone', 'first_name' => 'candidate_contact_details.first_name', // etc. );
then add things query (just untested example...):
foreach ($_post $key => $value) { if (array_key_exists($key, $post_map)) { $search[] = $post_map[$key] . '=' . mysql_real_escape_string($value); } }
Comments
Post a Comment