title: Dynamic PHP that creates navbar from SQL
body: <p>I am trying to figure out where I went wrong with my code.
  I built my navbar with php in the unordered list of the navbar to retrieve the menu elements from an SQL table called "menu" from a database called "shop", with no avail.
  I even have a print_r in place, only to show me that my resource is working, but for some reason the whole code isn't creating the menu items as written.</p>
  
  <p>This is the code:</p>
  
  <pre><code>    &lt;?php 
  $menu = [];
  mysql_connect('localhost', 'root', '');
  mysql_select_db('shop');
  
  $result=  mysql_query("SELECT * FROM menu");
  if ($result &amp;&amp; mysql_num_rows($result)&gt;0){
  
      while($row = mysql_fetch_assoc($result)){
          $menu[] = $row;
      }
  }
  echo '&lt;pre&gt;';
  $error= print_r($menu);
  $error = '' ;
   echo '&lt;/pre&gt;';
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
      &lt;head&gt;
          &lt;link href="_CSS/style.css" rel="stylesheet" type="text/css"/&gt;
              &lt;title&gt;TODO supply a title&lt;/title&gt;
          &lt;meta charset="UTF-8"&gt;
          &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div class="site-wrapper"&gt;
              &lt;div class="header"&gt;
                  &lt;div class="navbar"&gt;
                  &lt;ul&gt;
                      &lt;li&gt;&lt;a href="./"&gt;Home&lt;/a&gt;&lt;/li&gt;
                      &lt;?php if(count($menu) &gt;0) : ?&gt;
                      &lt;?php foreach ($menu as $row) : ?&gt;
                      &lt;li&gt;&lt;a href="#"&gt;&lt;?php $row = ['link']; ?&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;?php endforeach; ?&gt;
                          &lt;?php endif; ?&gt;
                  &lt;/ul&gt;
                  &lt;/div&gt;       
                 &lt;div class="member"&gt;
                      &lt;ul&gt;
                          &lt;li&gt;&lt;a href="../login.php"&gt;&lt;/a&gt;Login&lt;/li&gt;
                          &lt;li&gt;&lt;a href="../Register.php"&gt;&lt;/a&gt;Register&lt;/li&gt;
                      &lt;/ul&gt;
                  &lt;/div&gt;
                 &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>The result unfortunately looks like this:
  <a href="https://i.stack.imgur.com/h0TcK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h0TcK.png" alt="enter image description here"></a></p>