You simply have to pass second params of mysqli_fetch_array to get desired result
$sql = "SELECT * FROM contacts";
$result = mysqli_query($connect, $sql);
$response = array();
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { //<-----------change this
$response[] = $row;
}
print json_encode($response);
// Close connection
mysqli_close($connect);
EDIT
OR you can use mysqli_fetch_assoc($result)
to get associative array
See the manual : http://php.net/manual/en/mysqli-result.fetch-array.php
1
solved JSON data output from database