i used this script to convert all data to json by using json_encode
$response = array();
$con=mysqli_connect("localhost","root","","market");
// Check connection
if (mysqli_connect_errno())
{
die ("Failed to connect to MySQL: " . mysqli_connect_error());
}
$myData = array();
$result = mysqli_query($con, "SELECT * FROM `item`");
while ($row = mysqli_fetch_assoc($result))
{
$myData[] = $row;
}
echo json_encode($myData, JSON_UNESCAPED_UNICODE);
when I used this script the result is empty. I check the connection and query via write echo method inside while loop. the result written and not has problem in connection and query, because in each loop is give me the array.
while ($row = mysqli_fetch_assoc($result))
{
$myData[] = $row;
echo json_encode($myData, JSON_UNESCAPED_UNICODE);
}
And i want just one array for all my data I don't know where is the problem.
I hope my question is clear