<form name="myForm" action="doControlAcc.php" method="post" onsubmit="return validateForm(this);">
<table cellpadding="0" cellspacing="0" border="20" class="display" id="acc" width="200">
<thead>
<tr><h2>Accessories summary</h2></tr>
<tr>
<th>Type</th>
<th>Currently - Ex Factory</th>
<th>Minimum Required Stock</th>
<th>Update by</th>
<th>Last update</th>
<th>Re-Stock Amount</th>
<th>Stock Out</th>
</tr>
</thead>
<tbody>
<?php
$accessories = array()
$query = "SELECT description, current_stock, min_required_stock, c_ex_factory, last_update from Accessories”;
$result= mysqli_query($link, $query) or die(mysqli_error($link));
$row = mysqli_fetch_array($result);
while($row = mysqli_fetch_array($result)){
$order = $row['c_ex_factory'] - $row['min_required_stock'];
if ($order < 0){
$order = $row['min_required_stock']-$row['c_ex_factory'];
$color = "#FF0000";
}else{
$order = 0;
$color = "#00FF00";
}
?>
<tr>
<td name="accessories[]" id="accessories" value=”<?php echo $row['description'] ?>” <?php echo in_array($row['description', $ accessories) > <?php echo $row['description']; ?> </td>
<td align="center" name="accessories[]" id="accessories" value=”<?php echo $row[''c_ex_factory '] ?>” <?php echo in_array($row[''c_ex_factory ', $ accessories) > <?php echo $row['c_ex_factory']; ?> </td>
<td align="center" name="accessories[]" id="accessories" value=”<?php echo $row[''min_required_stock '] ?>” <?php echo in_array($row[''min_required_stock ', $ accessories) > <?php echo $row['min_required_stock']; ?> </td>
<td align="center" name="accessories[]" id="accessories" value=”<?php echo $row[' name '] ?>” <?php echo in_array($row[' name ', $ accessories) > <?php echo $row['name']; ?> </td>
<td align="center" name="accessories[]"id="accessories" value=”<?php echo $row['description'] ?>” <?php echo in_array($row['description', $ accessories) > <?php echo $row['up_when']; ?> </td>
<td align="center" name="accessories[]" bgcolor="<?php echo $color; ?>" id="accessories" <?php echo in_array($row[' re_stock ', $ accessories) > <input type="text" size="5" name="re_stock" value=" <?php echo $order ?>"/> </td>
<td align="center" name="accessories[]"id="accessories" <?php echo in_array($row[' out_stock ', $ accessories) > <input type="text" size="5" name="out_stock" value ="0"/></td>
</tr>
<?php
}
?>
<tr>
<td> </td>
<td> </td>
<td></td> <td></td> <td></td>
<td><button data-theme="b" id="submit" type="submit">Send order</button></td>
</tr>
</tbody>
</table>
</form>
你好我是网络编程的新手。上面的代码将从数据库中获取数据以在 PHP 中创建一个表,然后它将获取用户输入的缺货和补货,并将其发送到 doControlAcc.php 文件。我面临的问题是我需要创建多个输入行,以便用户可以输入不同产品的缺货和补货。而且我不知道如何在填写表单后将这些多行传递给doControlAcc.php文件。(即如何在doControlAcc.php中访问附件阵列?
感谢您的帮助。
这可能不是最好的方法,但您始终可以使用会话变量。我不太理解您正在编写的程序,所以我不能说会话是否足够安全,但是如果您想使用会话,请执行以下操作:
在文件的开头:
<?php
session_start();
?>
稍后,当变量全部设置好时:
$_SESSION['accessories'] = $accessories;
若要在另一个代码文件中访问它,必须启动会话,如上每个代码文件中所示。然后,就这样做;
$accessories = $_SESSION['accessories'];