Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd HTML dynamic table values Into Single INSERT statement
    primarykey
    data
    text
    <p>This is my Main Page which is adding dynamic rows inside table(jQuery is performing this),since i have 'n' number of rows to add,how can i perform SQL insert statement for all dynamic number of rows(with 4 different textfields).</p> <p>In Simple,i have- (1,2,3,x,y,z)elements as Insert statement values,where x,y,z can be any number of rows(but every time x,y,z will be equal number of elements),along with 1,2,3 i need to add this array of x,y,z. FOR loop inside insert statement is what i get from google n stackOverflow but how do u FOR loop 4 different textfields along with 1,2,3(pre-defined elements)</p> <p>More Simpler- </p> <pre><code>(value1,value2,value3,x,y,z); (value1,value2,value3,a,b,c); (value1,value2,value3,e,f,g); (value1,value2,value3,q,w,e); (value1,value2,value3,a,s,d); </code></pre> <p>How do u insert this above inside MySQL single INSERT statement?</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script src="http://code.jquery.com/jquery-1.5.1.min.js"&gt;&lt;/script&gt; &lt;script src="jquery.json-2.4.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function() { var id = 0; // Add button functionality $("table.dynatable button.add").click(function() { id++; var master = $(this).parents("table.dynatable"); // Get a new row based on the prototype row var prot1= master.find(".prototype").clone(); prot1.attr("class", "") prot1.find(".id").attr("value", id); master.find("tbody").append(prot1); alert(id); }); // Remove button functionality $("table.dynatable button.remove").live("click", function() { $(this).parents("tr").remove(); }); //Submit button clicked $('#button').click(function() { //$("table tr").has("th").remove(); var data = { value : [] } $("table tbody tr").each(function() { data.value.push($('.id', this).val()); data.value.push($('.WID', this).val()); data.value.push($('.ac', this).val()); data.value.push($('.tm', this).val()); data.value.push($('.cutt', this).val()); }); console.log(data); var id = data.value.join(','); alert(id); var myarr1={final:data}; var myarr2=JSON.stringify(myarr1); var myarr3="receivearray.php?url=" + encodeURIComponent(myarr2); $('#myFrame1').attr("src", myarr3); }); }); &lt;/script&gt; &lt;style&gt; .dynatable { border: solid 1px #000; border-collapse: collapse; } .dynatable th, .dynatable td { border: solid 1px #000; padding: 2px 10px; width: 170px; text-align: center; } .dynatable .prototype { } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;table id="MyTable" class="dynatable"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;WID&lt;/th&gt; &lt;th&gt;InchargeName&lt;/th&gt; &lt;th&gt;Action&lt;/th&gt; &lt;th&gt;Time&lt;/th&gt; &lt;th&gt;&lt;button class="add"&gt;Add&lt;/button&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr class="prototype" id="pro"&gt; &lt;td&gt;&lt;input type="text" name="id[]" value="" class="id" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="name[]" value="" class="WID"/&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="col4[]" value="" class="ac" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="col3[]" value="" class="tm"/&gt;&lt;/td&gt; &lt;td&gt;&lt;button class="remove"&gt;Remove&lt;/button&gt; &lt;/tr&gt; &lt;/table&gt; &lt;input type="button" id="button" value="submit"/&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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