can anyone help me on this. I'm trying to fetch all the data from table. but it keeps returning as boolean.
<?php
$con = mysqli_connect("localhost", "root", "", "student");
$query = "SELECT * FROM `announcement` ORDER BY `announce_id` DESC";
$result = mysqli_query($con, $query);
while($row = mysqli_fetch_assoc($result)){
$data[] = $row;
}
echo json_encode($data);
?>
The error given was:
> Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result,
> boolean given in D:\Xampp\htdocs\student\announcement.php on line 8
>
> Notice: Undefined variable: data in
> D:\Xampp\htdocs\student\announcement.php on line 12 null