I'm a complete newbie. I want to display comma separated values ββfrom a database in tabular form
From the image link below, we see how the data is added, separated by commas:

I want to display in tabular form on an html / php page as shown below:

This is my html page below: -
<form action="insert.php" method="POST"> <div id="items"> <input type="text" placeholder="name" name="user_name[]" /> <input type="text" placeholder="email" name="user_email[]" /> </div> <input type="button" value="add entry" id="add"/> <input type="submit" value="submit"/>

Javascript file to add additional input: -
$(document).ready(function(){ $("#add").click(function (e){ event.preventDefault() $('#items').append('<div><input type="text" placeholder="Name" name="user_name[]" ><input type="text" placeholder="email" name="user_email[]">' +'<input type="button" value="delete" id="delete"/></div>'); }); $('body').on('click','#delete',function(e){ $(this).parent('div').remove(); }); });
And below is the PHP code to insert into the database: -
<?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) ?>
source share