Wednesday, 29 August 2018
Subscribe to:
Post Comments (Atom)
$sql = "SELECT * FROM People";
$result = $conn->query($sql);
$json_array = array();
if ($result->num_rows > 0) {
// output data of each row
$row = $result->fetch_assoc();
foreach($row as $key => $value) {
echo "" . $key . ": " . $value;
echo "<br>";
$json_array[] = array(''=>$key, ''=>$value);
}
} else {
echo "0 results";
}
echo json_encode($json_array);
$conn->close();
?>
$result->fetch_assoc();
returns an associative array.$json_array[] = array(''=>$key, ''=>$value);
[{"":"Mark"},{"":"ABC"},{"":"25"}]
$json_array[] = array( $key => $value );
$json_array[] = array(''=>$key, ''=>$value);
Hello Friends! I am Ramana a part time blogger from Hyderabad.
0 comments:
Post a Comment