我创建了Multi步骤表单,它有三个步骤,带有继续按钮,最后有一个提交按钮,我可以将单个值添加到我的数据库中但是为动态字段编写的php代码不起作用,在这里你可以看到我的表格。我已经给了我的PHP代码
表单网址 http://bootsnipp.com/snippets/XaXnv
<?php
$mysql_host = 'localhost';
$user_name = 'root';
$sqlpw = '';
$database = 'jobfor_u';
$con = mysqli_connect($mysql_host, $user_name, $sqlpw, $database) or die("error.mysql_error($con)");
if (isset($_POST['submit'])) {
$edu_lvl_arr = $_POST['edu_level'];
$edu_fld_arr = $_POST['field_stu'];
$univer_arr = $_POST['university'];
$edu_frm_arr = $_POST['edu_from'];
$edu_to_arr = $_POST['edu_to'];
for ($i = 0; $i < count($edu_lvl_arr); $i++) {
$edu_levl = mysqli_real_escape_string($con, $edu_lvl_arr[$i]);
$ed_fld = mysqli_real_escape_string($con, $edu_fld_arr[$i]);
$univr = mysqli_real_escape_string($con, $univer_arr[$i]);
$ed_frm = mysqli_real_escape_string($con, $edu_frm_arr[$i]);
$ed_to = mysqli_real_escape_string($con, $edu_to_arr[$i]);
$sql2 = mysqli_query($con, "INSERT INTO candi_education(can_edu_level,can_field_stu,edu_tim_from,edu_tim_to)
VALUES('$edu_levl','$ed_fld','$univr',$ed_frm,$ed_to)");
}
}
?>
答案 0 :(得分:0)
VALUES('$edu_levl','$ed_fld','$univr',$ed_frm,$ed_to)
为值上的变量添加单个冒号。
VALUES('$edu_levl','$ed_fld','$univr','$ed_frm','$ed_to')