title: Display Php Array result in an Html table
body: <p>I was trying to display an array in php to an HTML table but there's an issue. I found several examples here in stack overflow, but they don't work for my case. </p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>&lt;?php include('inc/db_connect.php');?&gt;
  
  &lt;?php
  try
  {
    $sql = "SELECT id GroupName, VideoTITLE, ByArtist FROM videoclip";
    $result = $pdo-&gt;query($sql);
  }
  catch(PDOException $e)
  {
    $error = 'unable to fetch data: '.$e-&gt;getMessage();
    include'error.html.php';
    exit();
  }
  $URLS = array();
  while ($row = $result-&gt;fetch())
  {
    $URLS[] = array('id' =&gt; $row['id'], 'GroupName' =&gt; $row['GroupName'], 'VideoTITLE' =&gt; $row['VideoTITLE'], 'ByArtist'=&gt; $row['ByArtist'] );
  }
  </code></pre>
  
  <p><strong>html:</strong></p>
  
  <pre><code>&lt;div id="table_admin" class="span7"&gt;
          &lt;h3&gt;Videoclip List&lt;/h3&gt;
  
          &lt;table class="table table-striped table-condensed"&gt;
  
                  &lt;thead&gt;
                  &lt;tr&gt;
                  &lt;th&gt;Song name&lt;/th&gt;
                  &lt;th&gt;Group name &lt;/th&gt;
                  &lt;th&gt;Artist &lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;/thead&gt;
              &lt;?php foreach ($URLS as $URL){
                  echo'&lt;tbody&gt;';
                  echo'&lt;tr&gt;'; 
                  echo'&lt;td&gt;'. $row['VideoTITLE']."&lt;/td&gt;";
                  echo'&lt;td&gt;'. $row['GroupName'].'&lt;/td&gt;';
                  echo'&lt;td&gt;'. $row['ByArtist'].'&lt;/td&gt;';
                  echo'&lt;tr&gt;';
                  echo'&lt;/tbody&gt;';
                }
              ?&gt;
  
          &lt;/table&gt;
  
      &lt;/div&gt;
  </code></pre>