I'm having trouble comparing the value returned from a get request to a variable. The get returns in a format that includes the row in the databases name along with the value. Since the variable does not have that "tag" too they don't compare correctly. Is there a way to compare them properly?
{"email":"[value]"}
Thats the format its returning in. The value is in an array.
$app->get('/api/user_info/{email}', function($request, $response) {
require_once('dbconnect.php');
$email = $request->getAttribute('email');
$query = "select email from user_info";
$result = $mysqli->query($query);
$count = 0;
while($row = $result->fetch_assoc()){
$data[] = $row;
}
for ($i=0; $i < count($data); $i++){
if($data[$i] == ($email)){
$newResponse = $response->withjson($data[$i]);
return $newResponse;
//Should return email if they're the same
}
else {
$count += 1;
}
if ($count == count($data)){
$newResponse = $response->withjson("Email not found");
return $newResponse;
}
}
});