I try to do a search on a CVs application, which stored in many tables, and I'm trying to find a CV that has a specific information like (qualifications and educations).
So I have sent the search criteria via POST:
$_POST['qualifications'] = array(5,9) and <br>
$_POST['educations'] = array(13);
and I wanna to find the cvs that has just that information.
the tables are look like:
cv_qualifications table: id, resume_id , qualifications_id.<br>
cv_educations table : id, resume_id , educations_id.
I have tried to use (WHERE IN statements):qualifications
select * FROM cv_qualifications where qualifications_id IN (19,5);
select * FROM cv_educations where educations_id IN (13);
but that statements bring all CVs which have qualifications_id 19 or qualifications_id 5 or educations_id = 13.
This is my code:
$keys = array_keys($_POST);
$found = array();
foreach ($keys as $key) {
$found[$key] = DataBase::query("SELECT * FROM cv_" . $key . " WHERE " . $key . "_id IN (?)", array($_POST[$key]));
}
echo count($found)."\n";
print_r($found)."\n";
whereclause as needed. You also shouldn't execute multiple times do 1 execution and build the query dynamically.