-2
Hi, I’m having a problem with my code and I wanted your help.
I need to take data from a table and send it as json, I have 10 items in my table but json only sends one.
Table: local
In my code where I put all PHP and Msqli
include("connect.php");
header("Content-Type: application/json");
$queryString = "SELECT * FROM `local`";
$query = mysqli_query($conexao, $queryString) or die(mysqli_error());
$paises = array();
while ($pais = mysqli_fetch_assoc($query)) {
$paises['paises'] = $pais['paises'];
}
echo json_encode($paises);
And he only returns me the last item that is "Argentina" and it was the most that I could because I have tried several ways. If you can help me there I appreciate.
Display the json array result with a
print_r()
to see what is being displayed. print_r(json_encode($paises));– José Dam