I have a table "payment_forms" and I made an API to get all these forms of payment, but even the database is correct, it informs that the "name" field is null in return, see:
[{"nome":"Dinheiro"},{"nome":"Cheque"},{"nome":null},{"nome":null}]
And it is not "null" and only these two appear.
Follow my PHP:
PHP:
<?php
header('Content-type: application/json');
header('Access-Control-Allow-Origin: *');
include 'database.php';
//$cod_fornecedor=$_GET['cod_fornecedor'];
$query="SELECT
nome
FROM
formas_pagamento
ORDER BY
cod_forma_pagamento ASC";
$result=$con->query($query);
$row_cnt = mysqli_num_rows($result);
if ($result->num_rows > 0)
{
$count=0;
echo "[";
while($row = $result->fetch_assoc())
{
$count++;
echo json_encode($row);
if($count!=$row_cnt)
{
echo ",";
}
}
echo "]";
}
else
{
echo "error";
}
?>
What's wrong?