Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $("#append").click(function (e) {
- e.preventDefault();
- var textboxes = $(".textbox").length;
- $(".inc").append("<div class='controls'><input class='textbox form-control' type='text' name='textbox[]'><input class='textbox form-control' type='text' name='box[]' ><input class='textbox form-control' type='text' name='box1[]' ><input class='textbox form-control' type='text' name='box2[]' ><a href='#' class='remove_this btn btn-danger'>remove</a> </div>");
- });
- $(document).on('click', '.remove_this', function (e) {
- e.preventDefault();
- $(this).parent().remove();
- });
- <form class="form-horizontal" method= "POST">
- <div class="control-group">
- <div class="inc">
- <div class="controls">
- <button style="margin-left: 50px" class="btn btn-info" type="submit" id="append" name="append">
- Add Textbox</button>
- <br>
- <br>
- </div>
- </div>
- <input type="submit" class="btn btn-info" name="submit" value="submit"/>
- </div>
- $host = "localhost";
- $dbname = "lala";
- $user = "root";
- $pass = "";
- $conn = new PDO("mysql:host=$host; dbname=$dbname", $user, $pass);
- if (isset($_POST['submit'])) {
- $textboxes = $_POST['textbox'];
- $textboxes1 = $_POST['box1'];
- $textboxes2 = $_POST['box2'];
- $boxes = $_POST['box'];
- $x=0;
- $a=0;
- $z=0;
- foreach ($textboxes as $textbox ) {
- $y=0;
- if($y==$x){
- foreach ($boxes as $box ) {
- if($z==$y){
- foreach ($textboxes1 as $box1 ) {
- if($a==$z){
- foreach ($textboxes as $box2 ) {
- if($y==$x){
- $sql = "INSERT into sasa (sasa,sasa1,sasa2,sasa3) values('$textbox','$box','$box1','$box2')";
- echo $sql . "<br>";
- $q = $conn->query($sql);
- }
- $x++;
- $y++;
- }
- }
- $a++;
- }
- }
- $z++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment