Hello,
I'm using the following code to return the regions:
$query = 'SELECT * FROM Regiao';
$json = array();
$result = mysqli_query ($conn, $query);
while($row = mysqli_fetch_array ($result))
{
$regiao = array(
'id' => $row['Id'],
'nome' => $row['Nome'],
);
array_push($json, $regiao);
}
$jsonstring = json_encode($json);
echo $jsonstring;
die();
The result is as follows:
[
{
"id": "1",
"nome": "Norte"
},
{
"id": "2",
"nome": "Nordeste"
},
{
"id": "3",
"nome": "Sudeste"
},
{
"id": "4",
"nome": "Sul"
},
{
"id": "5",
"nome": "Centro-Oeste"
}
]
I'm using the same code but in another file with the different select:
$query = 'SELECT * FROM Estado';
$json = array();
$result = mysqli_query ($conn, $query);
while($row = mysqli_fetch_array ($result))
{
$regiao = array(
'id' => $row['Id'],
'codigouf' => $row['CodigoUf'],
'nome' => $row['Nome'],
'uf' => $row['Uf'],
'regiao' => $row['Regiao'],
);
array_push($json, $regiao);
}
$jsonstring = json_encode($json);
echo $jsonstring;
die();
And the result in the second code is Blank, it does not return anything at all. Could someone help me please? Thanks