The problem I have is that I do not know if I'm wrongly implementing the fetch_assoc
or keeping the records wrong in the ' array because when checking if the $ stmt- & gt query ; execute () fails, tells me that it is correct and does not return anything.
The query should return more than 2 records and then manage them in another file where I will send them to android using echo
with json_encode
.
public function searchMiembrosGrupo($id_grupo){
$stmt = $this->conn->prepare("SELECT 'email_padre','nombre_hijo' FROM 'hijos' INNER JOIN 'user' WHERE 'hijos'.'email_padre' = 'user'.'email' AND 'user'.'grupo' = ?");
$stmt->bind_param("s", $email);
$stmt->execute();
while ($row = $stmt->get_result()->fetch_assoc()) {
$miembros_grupo[] = $row;
}
return $miembros_grupo;
}
SearchMember.php
<?php
require_once 'include/DB_Functions.php';
$db = new DB_Functions();
// json response array
$response = array("error" => FALSE);
if (isset($_POST['id_grupo'])) {
// receiving the post params
$id_grupo = $_POST['id_grupo'];
// get the user by email and password
var_dump($user = $db->searchMiembrosGrupo($id_grupo));
//$user = $db->searchMiembrosGrupo($id_grupo);
if ($user != false) {
// user is found
$response["error"] = FALSE;
$response["user"]["email_padre"] = $user["email_padre"];
$response["user"]["nombre_hijo"] = $user["nombre_hijo"];
echo json_encode($response);
} else {
// user is not found with the credentials
$response["error"] = TRUE;
$response["error_msg"] = "Los datos estan mal. Por favor intenta nuevamente!";
echo json_encode($response);
}
} else {
// required post params is missing
$response["error"] = TRUE;
$response["error_msg"] = "Se requiere el dato (id de grupo). Intentalo nuevamente!";
echo json_encode($response);
}
?>