我试图在网上寻找解决方案,但我不知道该如何提出。
line_id总是给出最后一个值,我知道它会被一会儿覆盖,但是我可以算出如何为mysql更新获取正确的id。我是否需要发布整个数组,或者我只是缺少一些简单的东西?
看了几个小时,在这里和那里换位,让我有些困惑。
<form method="post">
<?php
if ($order_search->num_rows > 0) {
// output data of each row
$i=-1;
while ($detail = mysqli_fetch_array($order_search))
{
$i++;
$new_line_id[] = $detail[0];
echo "<td>";
echo "<select name='type'>";
while ($row = mysqli_fetch_array($item_search))
{
echo "<option value='iname' ".($row[1] == $detail[1] ? 'selected' : '').">$row[1]</option>";
}
mysqli_data_seek($item_search,0);
echo "<input type='hidden' name='iname_id' value='$row[0]'>";
echo "</select>";
echo "</td>";
echo "<td>";
echo "<input type='text' name='qty' value='$detail[2]'>";
echo "</td>";
echo "<td>";
echo "<select name='temp'>";
while ($trow = mysqli_fetch_array($temp_search))
{
echo "<option value='tname' ".($trow[1] == $detail[3] ? 'selected' : '').">$trow[1]</option>";
}
mysqli_data_seek($temp_search,0);
echo "</select>";
echo "</td>";
echo "<td>";
echo "<input type='date' name='from' value='$detail[4]'>";
echo "</td>";
echo "<td>";
echo "<input type='date' name='to' value='$detail[5]'>";
echo "</td>";
echo "<td>";
echo "<input type='submit' name='accept' value=',/".$i."'>";
echo "</td>";
echo "<td>";
echo "<input type='submit' name='delete' value='X'>";
echo "</td>";
echo "</tr>";
}
echo "<input type='hidden' name='line_id' value='".$i."'>";
echo "<input type='hidden' name='entry_id' value=".$entry_id.">";
echo "<input type='hidden' name='order_id' value=".$order_id.">";
print_r($new_line_id);
echo $_POST['line_id'];
}
echo "<input type='hidden' name='line_id' value='".$i."'>";
if (isset($_POST['accept'])) {
$line_id = $_POST['line_id'];
echo $line_id;
}
?>
</form>