I have put together a very complicated search form. Using arrays I have managed to get it searching by checkboxes.
if(isset($_POST['search']) && !empty($_POST['search'])){
foreach($_POST['search'] as $key=>$value){
if($value==1) $search[] = "$key";
}
$searchstring = implode(' AND ', $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 FROM candidate_id, candidate_contact_details, qualifications, security_experience, previous_career WHERE qualifications.active = 'finished' and candidate_id.master_id = candidate_contact_details.c_id and candidate_id.master_id = qualifications.c_id and $searchstring";
I know how to do searches of the database by a specific term. ie. postcode field but does anyone know how I can add that to this query? I know how to do either checkbox based searches or text field based searches but cannot figue out how to combine the two.
Thanks Again
Jason
As far as I can understand your question, you need to map the names of the form fields to database columns. You could set up an array like:
Then you could add things to your query like (just an untested example…):