Hello i have recently been making an attempt at creating a forum and am currently working on my forum index page. I have only recently started getting into PHP and have done it for around 2 weeks.
I dont understand what exactly i need to fix the error from coming up, but its obviously in relation to my use of mysqli_num_rows and mysqli_fetch_assoc. i find it difficult to understand why it doesn't like the boolean response. If anyone could explain it i would appreciate it.The code stops at the second error message "No categories have been added by admin" and The code below is what i have so far:
<?php
include 'connect.php';
include 'header.php';
$sql = "SELECT
      cat_id,
      cat_name,
      cat_description,
      FROM
      categories";
$result =mysqli_query($link, $sql);
    if(!isset($result))
    {
        echo 'Error while selecting from database.Please try again later.';
    }
    else
    {
if(mysqli_num_rows($result)== 0)
     {
         echo 'No categories have been added by Admin';
     }
 else
 {
     echo '<table border="1">
          <tr>
          <th>Category</th>
          <th>Last Topic</th>
          </tr>';
 while ($row =mysqli_fetch_assoc($result))
 {
     echo '<tr>';
         echo '<td class="leftpart">';
             echo '<h3><a href="category.php?id">' . $row['cat_name'] . '</a></h3>' . $row['cat_description'];
         echo '</td>';
         echo '<td class="rightpart">';
                     echo '<a href="topic.php?id=">Topic Subject</a> at 10-10';
         echo '</td>';
     echo '</tr>';
 }
 }
    }
include 'footer.php';
?>
 
     
    