我正在尝试使用 php 从动态创建的数据库中添加删除字段插入数据,但无法执行。我只能从原始表单插入数据。
我的表格看起来像这样。请帮助我。
我的数据看起来像这样
<?php
require_once "conn.php";
$ch_direction= $ch_direction_through==$reg_id="";
if($_SERVER["REQUEST_METHOD"] == "POST"){
for ($i=0; $i < count($_POST['ch_direction']); $i++ )
{
$ch_direction = trim($_POST["ch_direction"][$i]);
$ch_direction_through = trim($_POST["ch_direction_through"][$i]);
$reg_id= $_POST['reg_id'][$i];
$sql = "INSERT INTO bps_registration_charkilla (ch_direction, ch_direction_through,reg_id) VALUES (?, ?, ?)";
if($stmt = mysqli_prepare($conn, $sql)){
mysqli_stmt_bind_param($stmt, "sss",$ch_direction, $ch_direction_through, $reg_id);
$reg_id=$reg_id;
$ch_direction=$ch_direction;
$ch_direction_through=$ch_direction_through;
if(mysqli_stmt_execute($stmt)){
if(!empty($reg_id)){
$success = "Submitted form successfully sent";
header("location: registration_detail.php?success=$success&id=".$reg_id);
exit();
} else {
header("location: registration_detail.php");
exit();
}
} else {
echo "Something went wrong. Please try again later.";
}
}
}
mysqli_close($conn);
}
?>
$(document).ready(function() {
var max_fields = 15; //maximum input boxes allowed
var wrapper = $(".input_fields_wrap"); //Fields wrapper
var add_button = $(".add_field_button"); //Add button ID
var x = 1; //initlal text box count
$(add_button).click(function(e){ //on add input button clicf k
e.preventDefault();
if(x < max_fields) { //max input box allowed
x++; //text box increment
}
});
$(wrapper).on("click",".remove_field", function(e) { //user click on remove text
e.preventDefault();
$(this).parent('div').remove(); x--;
});
});
达令说
宝慕林4294392