public function getUsers name town education idEducationQuery this- db

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
public function getUsers($name, $town, $education){
$idEducationQuery = $this->db->prepare("SELECT * FROM education WHERE educationName = ?");
$idTownQuery = $this->db->prepare("SELECT * FROM town WHERE townName = ?");
$idEducationQuery->execute(array($education));
$idTownQuery->execute(array($town));
$idEducation = $idEducationQuery->fetchAll(PDO::FETCH_ASSOC);
$idTown = $idTownQuery->fetchAll(PDO::FETCH_ASSOC);
foreach ($idEducation['education'] as $ed) {
foreach ($idTown['town'] as $to) {
$usersQuery = $this->db -> query("SELECT * FROM users WHERE name= " . $name . " AND town =" . $to . " AND education =" . $ed);
if ($usersQuery->fetchAll(PDO::FETCH_ASSOC)[0] != NULL){
$users2 = $usersQuery->fetchAll(PDO::FETCH_ASSOC);
foreach ($users2 as $user)
$users[] = new User($user['name'], $user['town'], $user['education']);
}
}
}
return $users;
}