我不知道这段代码有什么问题,但是每当我选择要填写的多个表格时,只会显示数据的最后一部分。例如,我会选择 3 个表格并用仅存储最后一个表格的数据填充它。我使用这段代码来显示应该在数组中的数据。
echo "<pre>";
print_r($_POST);
echo "</pre>";
这是我的代码,请帮助我
<?php
// $_POST['countEmp'] is a variable from another page that would determine
// how many loops that it should execute
$count = $_POST['countEmp'];
$sql = "SELECT * FROM position";
$res = mysqli_query($conn,$sql);
$flag = 0;
for ($i=0; $i < $count; $i++) {
echo " <form method='POST' action=insertProject1.php> ";
echo " <input type='text' name='employee[]' placeholder='employee's name'> ";
echo "<select name='position[]'>";
echo "<option selected='selected'>POSITION</option>";
while ($data = mysqli_fetch_assoc($res)) {
echo "<option value=".$data['position_id'].">".$data['position']."</option>";
}
echo "</select>";
echo "<br>";
$flag++;
if ($flag== $count) {
echo "<input type='submit' value='SUBMIT' name='insert'>";
}
mysqli_data_seek($res,0);
echo " </form> ";
}
?>