I have a db table that has two columns, id and category. my aim is to use a while loop to echo out the category from the db into a li and an anchor.
Here's the code:
<ul class="nav navbar-nav">
                    <?php $connect = new db();
                          $stmt = $connect->link->query("SELECT * FROM categories")->fetchall();
                          while($row = $stmt){
                            $category = $row["category"];
                            echo "<li><a href='#'>{$category}</a></li>";
                          }
                    ?>
                </ul>
i am getting an error but it doesnt make sense to me. its saying undefined index "category". its referring to where i assigned $category to the $row[].
i know for sure that the data is being pulled because i used the print_r() function and it printed them out
edit: as requested the output from a var_dump()
C:\wamp64\www\cms\CMS_TEMPLATE\includes\nav.php:21:
array (size=4)
  0 => 
    array (size=4)
      'category_id' => string '1' (length=1)
      0 => string '1' (length=1)
      'category' => string 'bootstrap' (length=9)
      1 => string 'bootstrap' (length=9)
  1 => 
    array (size=4)
      'category_id' => string '2' (length=1)
      0 => string '2' (length=1)
      'category' => string 'javascript' (length=10)
      1 => string 'javascript' (length=10)
  2 => 
    array (size=4)
      'category_id' => string '3' (length=1)
      0 => string '3' (length=1)
      'category' => string 'html' (length=4)
      1 => string 'html' (length=4)
  3 => 
    array (size=4)
      'category_id' => string '4' (length=1)
      0 => string '4' (length=1)
      'category' => string 'css' (length=3)
      1 => string 'css' (length=3)
 
     
    