I'm using the IN() operator to fetch multiple data from MySQL in a single query. But I'm having issues adding the results in to an array.
$sql = "SELECT employeeName, sum(emID) as count1 FROM people WHERE dept IN (:department1,:department2,:department3)";
$stmt = $connnect->prepare($sql);
$stmt->execute(array(':department1'=>"design", ':department2=>"web", ':department3=>"copywriting"));
$rslts = $stmt->fetchAll(PDO::FETCH_ASSOC);
$cont = $rslts[0]['count1']
if($cont > 0){
$myArry['em1'] = $rslts[0]["employeeName"];
$myArry['em2'] = $rslts[1]["employeeName"];
$myArry['em3'] = $rslts[2]["employeeName"];
}
EDIT:
there was a typo. I've fixed it now. if(cont > 0){