php - How to add child table values associated to a parent table row? -


i have 2 nested tables in child table in parent table row. both tables can add row if needed clicking on add button.

i want insert child table values (that in parent first row) across parent 1st row , child table values (that in parent second row) across parent 2nd row.

currently code inserting child table value rows across parent first row , inserts again child table value rows across parent second row.

if (isset($_post['submit'])) {        ($i=0; $i<count($_post['size']); $i++){          $size = $_post['size'][$i];                    $qry1="insert product_size (product_size) values ('$size')";          $result1=mysqli_query($con,$qry1);         $product_size_id = mysqli_insert_id($con);                              ($j=0; $j<count($_post['color']); $j++){              $quantity = $_post['dress_quantity'][$j];              $color = $_post['color'][$j];              $qry2="insert product_color (product_size_id, product_color, product_quantity) values ('$product_size_id', '$color', '$quantity')";              $result2=mysqli_query($con,$qry2);              if($result2)             {                 echo '<script>alert("record added successfully!")</script>';                 echo '<script>window.location="try.php"</script>';             }             else                   {                 die("error while adding stock! please try again.");             }         }     } } 


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -