title: Creating a html table from a text file in PHP
body: <p>i am trying to create a 5 column html table from a list of names stored in a text file which are comma separated.</p>
  
  <p>I have got this far but I am far from a competent coder and need some help please. At the moment its displaying the table in one long column.</p>
  
  <pre><code>&lt;?php
  $f = fopen("names.txt", "r");
  while (!feof($f)) { 
  $arrM = explode(",",fgets($f));   
  
  $val = current  ( $arrM )  ;
  print "&lt;table border=1&gt;";
  while ( $val )
      {
        print "&lt;tr&gt; &lt;td&gt; $val &lt;/td&gt; ";
        $val = next ( $arrM) ;
        print "&lt;td&gt; $val &lt;/td&gt; &lt;/tr&gt; ";
        print "\n";
        $val = next ( $arrM );
      }
  
  print "&lt;/table&gt;";
  }
      ?&gt;
  </code></pre>
  
  <p>Thanks very much in advance</p>
  
  <p>RESOLVED... Heres the code for any Googlers looking for the same help.. </p>
  
  <pre><code>&lt;?php 
      $tdcount = 1; $numtd = 3; // number of cells per row 
      print "&lt;table&gt;"; 
      $f = fopen("names.txt", "r"); 
      while (!feof($f)) { 
          $arrM = explode(",",fgets($f)); 
          $row = current ( $arrM ); 
          if ($tdcount == 1) 
              print "&lt;tr&gt;"; print "&lt;td&gt;$row &lt;/td&gt;"; 
          if ($tdcount == $numtd) { 
              print "&lt;/tr&gt;"; 
              $tdcount = 1; 
          } else { 
              $tdcount++; 
          } 
      } 
      if ($tdcount!= 1) { 
          while ($tdcount &lt;= $numtd) { 
              print "&lt;td&gt;&amp;nbsp;&lt;/td&gt;"; $tdcount++; 
          } print "&lt;/tr&gt;"; 
      } 
      print "&lt;/table&gt;"; 
  ?&gt;
  </code></pre>