1๐
โ
$result
is not defined. You should use
if (!($result = $db->query($sql1))) { ...
or
$result = $db->query($sql1);
and only after you do
if (!$result) { ...
and
while ($row = mysqli_fetch_assoc($result)) { ...
Source:stackexchange.com