title: Seperate comma separated mySql database field value with php
body: <p>If you believe this is a duplicate please let me now as I'm not totally sure what to search for to check, (I will remove if duplicate)</p>
  
  <p>I have a list of of numbers in a mySql field called sess_times in a table called test_sess, the numbers for the first row are:</p>
  
  <p>25, 38, 40, 50</p>
  
  <p>is it possible to split these into php variable e.g:</p>
  
  <pre><code>$no1 = 25
  $no2 = 38
  $no3 = 40
  $no4 = 50
  </code></pre>
  
  <p>I'm trying to put the individual numbers in a table, something like below:</p>
  
  <pre><code>&lt;table cellspacing="0" cellpadding="0" border="0"&gt;
    &lt;tr&gt;
      &lt;td&gt; 1 &lt;/td&gt;
      &lt;td&gt;&lt;?php echo $no1; ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; 2 &lt;/td&gt;
      &lt;td&gt;&lt;?php echo $no2; ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; 3 &lt;/td&gt;
      &lt;td&gt;&lt;?php echo $no3; ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; 4 &lt;/td&gt;
      &lt;td&gt;&lt;?php echo $no4; ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Any help with this would be great so thanks in advance for any answers.</p>
  
  <p>HERE'S THE SOLUTION I USED, A COMBINATION OF 2 ANSWERS BELOW:</p>
  
  <pre><code>$data = '25,38,40,50';
  $string = explode(",", $data);
  $number = 0;
  echo '&lt;table cellspacing="0" cellpadding="0" border="0"&gt;';
  for($i=0; $i&lt;count($string); $i++)
  {
      $number = $number +1;
      echo '
          &lt;tr&gt;
              &lt;td&gt;' . $number . '&lt;/td&gt;
              &lt;td&gt;' . $string[$i] . '&lt;/td&gt;
          &lt;/tr&gt;
      ';
  }
  </code></pre>