What could be the reason for json_encode() not outputting anything after using fetch_all() in PHP?
The issue could be that fetch_all() returns an array of arrays, and json_encode() expects an associative array. To solve this, you can convert the fetched array to an associative array using array_map() with null as the callback function.
// Fetch data from database
$result = $stmt->get_result();
$data = $result->fetch_all(MYSQLI_ASSOC);
// Convert array of arrays to associative array
$data = array_map(null, $data);
// Encode data as JSON
echo json_encode($data);