Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to submit multiple data in mysql using php and jquery
    primarykey
    data
    text
    <p>how to submit multiple values in a table please help me im using this code this code submit only 1 entry in database but i want to enter multiples value in database how can i do this</p> <p>live demo <a href="http://jsfiddle.net/eruZC/3/" rel="nofollow">http://jsfiddle.net/eruZC/3/</a></p> <p>this is entry.html</p> <pre><code> &lt;script type='text/javascript' src='http://code.jquery.com/jquery-1.10.1.js'&gt;&lt;/script&gt; &lt;link rel="stylesheet" type="text/css" href="http://fiddle.jshell.net/css/result-light.css"&gt; &lt;style type='text/css'&gt; &lt;/style&gt; &lt;script type='text/javascript'&gt;//&lt;![CDATA[ $(window).load(function(){ $(document).ready(function(){ var id=1; $("#butsend").click(function(){ $("#table1").append('&lt;tr valign="top"&gt;&lt;td width="100px"&gt;'+(id++)+'&lt;/td&gt;&lt;td width="100px"&gt;'+$("#sname").val()+'&lt;/td&gt;&lt;td width="100px"&gt;'+$("#age").val()+'&lt;/td&gt;&lt;td width="100px"&gt;&lt;a href="javascript:void(0);" class="remCF"&gt;Remove&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;'); }); $("#table1").on('click','.remCF',function(){ $(this).parent().parent().remove(); }); }); });//]]&gt; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="submit.php" d="form1" name="form1" method="post"&gt; &lt;label&gt;Student Name&lt;/label&gt;&lt;input type="text" name="sname" id="sname"&gt;&lt;/br&gt; &lt;label&gt;Student Age&lt;/label&gt;&lt;input type="text" name="age" id="age"&gt;&lt;/br&gt; &lt;input type="button" name="send" value="Add" id="butsend"&gt;&lt;/br&gt; &lt;input type="button" name="submit" value="Submit" &gt;&lt;/br&gt; &lt;/form&gt; &lt;table id="table1" name="table1" border=""&gt; &lt;tbody&gt; &lt;tr&gt;&lt;th width="100px"&gt;ID&lt;/th&gt;&lt;th width="100px"&gt;Name&lt;/th&gt;&lt;th width="100px"&gt;Age&lt;/th&gt;&lt;th width="100px"&gt;&lt;/th&gt;&lt;tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>this is php page submit.php</p> <pre><code>&lt;?php /* NEW.PHP Allows user to create a new entry in the database */ // creates the new record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($sname, $age, $error) { ?&gt; &lt;?php // if there are any errors, display them if ($error != '') { echo '&lt;div style="padding:4px; border:1px solid red; color:red;"&gt;'.$error.'&lt;/div&gt;'; } ?&gt; &lt;?php } // connect to the database include('connect-db.php'); // check if the form has been submitted. If it has, start to process the form and save it to the database if (isset($_POST['submit'])) { // get form data, making sure it is valid $sname = mysql_real_escape_string(htmlspecialchars($_POST['sname'])); $age = mysql_real_escape_string(htmlspecialchars($_POST['age'])); // check to make sure both fields are entered if ($name == '') { // generate error message $error = 'ERROR: Please fill in all required fields!'; // if either field is blank, display the form again renderForm($sname, $age, $error); } else { // save the data to the database mysql_query("INSERT stock SET sname='$sname', age='$age'") or die(mysql_error()); // once saved, redirect back to the view page } } else // if the form hasn't been submitted, display the form { renderForm('','','','','','','',''); } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload