I have this in my php file:
$response = array();
$user = $db->test($email);
if ($user) {
// user stored successfully
$response["success"] = 1;
$response["user"]["email"] = $user["email"];
$response["user"]["imagepath"] = $user["imagepath"];
$response["user"]["about"] = $user["about"];
echo json_encode($response);
} else {
// user failed to store
$response["error"] = 1;
$response["error_msg"] = "JSON Error occured in db";
echo json_encode($response);
}
the test function is
public function test($email){
$result = mysql_query("SELECT * FROM activities WHERE email = '$email'");
// return user details
return mysql_fetch_array($result);
}
The test function is returning multiple rows, but the php sends the json only with the first row from the database that matches that email. How can I make a foreach() or something like that to encode everything that the test function returns ?