title: PHP mysql - Display comma separated value from the database in tabular form
body: <p>I am complete beginner 
  I want to display comma separated values from database in tabular form </p>
  
  <p>From the below image link we can see how the data is getting added separated by commas:</p>
  
  <p><img src="https://i.stack.imgur.com/rkvsE.jpg" alt="Databaseimage"></p>
  
  <p>I want to display in tabular form  in html/php page just like  below:</p>
  
  <p><img src="https://i.stack.imgur.com/BNovx.png" alt="Table image"></p>
  
  <p>This is my html page below:-</p>
  
  <pre><code>&lt;form action="insert.php" method="POST"&gt;
  
  &lt;div id="items"&gt;
      &lt;input type="text" placeholder="name" name="user_name[]" /&gt;
      &lt;input type="text" placeholder="email" name="user_email[]" /&gt;   
  &lt;/div&gt;
  
  &lt;input type="button" value="add entry" id="add"/&gt;
  &lt;input type="submit"  value="submit"/&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/QICmF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QICmF.jpg" alt="Html page"></a></p>
  
  <p>Javascript file for adding additional input:-</p>
  
  <pre><code>$(document).ready(function(){
  
  $("#add").click(function (e){
  event.preventDefault()
  $('#items').append('&lt;div&gt;&lt;input type="text" placeholder="Name"   name="user_name[]" &gt;&lt;input type="text" placeholder="email" name="user_email[]"&gt;'
  +'&lt;input type="button" value="delete" id="delete"/&gt;&lt;/div&gt;');    
  
  }); 
  
  $('body').on('click','#delete',function(e){
      $(this).parent('div').remove();
  });
  
  });
  </code></pre>
  
  <p>And below is the PHP code for inserting to database:-</p>
  
  <pre><code> &lt;?php
  $con = mysql_connect("localhost","root","");
  if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
  
  mysql_select_db("dynamic", $con);
  
  $user_name = $_POST["user_name"];
  $value = implode(',', $user_name); 
  $user_email = $_POST["user_email"]; 
  $valueone = implode(',', $user_email); 
  
  $sql="INSERT INTO dynamicdata (user_name, user_email)
  VALUES
  ('$value','$valueone')";
  
  if (!mysql_query($sql,$con))
    {
    die('Error: ' . mysql_error());
    }
  echo "1 record added";
  
  mysql_close($con)
  ?&gt;
  </code></pre>