I want to select all data for posts table according to department I tried to use this code but I got this error Call to a member function fetchAll() on boolean this is my code
<?php
if(isset($_GET['dept_n']))
{
$de_id = $_GET['dept_n'];
$sql = 'SELECT * FROM [posts WHERE dept_id = $de_id';
$result = $connection->query($sql);
$rows = $result->fetch_all();
foreach($rows as $row)
{
$id = $row[0];
echo" <img src='./images/$row[3].jpg' style='width: 90%; height: 200px; '>
<h4 >$row[1]</h4>
}}?>