Server IP : 162.240.98.243 / Your IP : 18.116.21.152 Web Server : Apache System : Linux server.bti.yaw.mybluehostin.me 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : btiyawmy ( 1003) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/btiyawmy/public_html/login.easenup.in/ |
Upload File : |
<!DOCTYPE html> <html> <head> <title>Webslesson Tutorial | Multiple Inline Insert into Mysql using Ajax JQuery in PHP</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" /> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> <script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script> <link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" /> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script src="https://www.jqueryscript.net/demo/Dialog-Modal-Dialogify/dist/dialogify.min.js"></script> <title>PHP - Sending multiple forms data through jQuery Ajax</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/js/standalone/selectize.min.js" integrity="sha256-+C0A5Ilqmu4QcSPxrlGpaZxJ04VjsRjKu+G82kl5UJk=" crossorigin="anonymous"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/css/selectize.bootstrap3.min.css" integrity="sha256-ze/OEYGcFbPRmvCnrSeKbRTtjG4vGLHXgOqsyLFTRjg=" crossorigin="anonymous" /> </head> <body> <br /> <h2 align="center">Multiple Inline Insert into Mysql using Ajax JQuery in PHP</h2> <br /> <div class="table-responsive"> <table class="table table-bordered" id="crud_table"> <tr> <td>Item Name</td> <td>Item Code</td> <td>Description</td> <td>Price</td> <td></td> </tr> <tr> <td contenteditable="true" class="item_name"></td> <td contenteditable="true" class="item_code"></td> <td contenteditable="true" class="item_desc"></td> <td contenteditable="true" class="item_price"></td> <td></td> </tr> </table> <div align="right"> <button type="button" name="add" id="add" class="btn btn-success btn-xs">+</button> </div> <div align="center"> <button type="button" name="save" id="save" class="btn btn-info">Save</button> </div> <br /> <div id="inserted_item_data"></div> </div> </body> </html> <script> $(document).ready(function(){ var count = 1; $('#add').click(function(){ count = count + 1; var html_code = "<tr id='row"+count+"'>"; html_code += "<td contenteditable='true' class='item_name'></td>"; html_code += "<td contenteditable='true' class='item_code'></td>"; html_code += "<td contenteditable='true' class='item_desc'></td>"; html_code += "<td contenteditable='true' class='item_price' ></td>"; html_code += "<td><button type='button' name='remove' data-row='row"+count+"' class='btn btn-danger btn-xs remove'>-</button></td>"; html_code += "</tr>"; $('#crud_table').append(html_code); }); $(document).on('click', '.remove', function(){ var delete_row = $(this).data("row"); $('#' + delete_row).remove(); }); $('#save').click(function(){ var item_name = []; var item_code = []; var item_desc = []; var item_price = []; $('.item_name').each(function(){ item_name.push($(this).text()); }); $('.item_code').each(function(){ item_code.push($(this).text()); }); $('.item_desc').each(function(){ item_desc.push($(this).text()); }); $('.item_price').each(function(){ item_price.push($(this).text()); }); $.ajax({ url:"23marchinsert.php", method:"POST", data:{item_name:item_name, item_code:item_code, item_desc:item_desc, item_price:item_price}, success:function(data){ alert(data); $("td[contentEditable='true']").text(""); for(var i=2; i<= count; i++) { $('tr#'+i+'').remove(); } fetch_item_data(); } }); }); function fetch_item_data() { $.ajax({ url:"23martchfetch.php", method:"POST", success:function(data) { $('#inserted_item_data').html(data); } }) } fetch_item_data(); }); </script>