1
請檢查下面的代碼。我需要把每個產品數量值輸入表格用戶。但產品/ ID是動態的並且來自數據庫。我如何接收和識別哪些產品的數量值將由用戶提交?我的意思是因爲產品是多重/動態來形式數據庫,所以我不能通過$ _POST ['ID']得到他們。那麼這種情況下的解決方案呢?從動態帖子名稱上的用戶接收多個輸入
<form method="post">
<table class="table table-hover">
<thead>
<tr>
<th>Stock Available</th>
<th>Product Name</th>
<th>Enter Order Quantity</th>
</tr>
</thead>
<tbody>
<?php
$q= mysqli_query($conn,"SELECT * FROM products");
while ($row=mysqli_fetch_array($q)) {
$id = $row['id'];
$product_name = $row['product_name'];
$available_stock = $row['available_stock'];
echo '
<tr>
<td>'.$available_stock.'</td>
<td>'.$product_name.'</td>
<td><input type="number" min="1" class="form-control" name="qty[]"></td>
<input type="hidden" name="id[]" value="'.$id.'">
<tr>
';
}
?>
</tbody>
</table><br><br>
<button type="submit" class="btn btn-success" name="submit_next_order2">Confirm This Order</button>
</form>
添加產品ID名稱= 「數量[] []」 然後 –
JYoThI
ok..good想法如何從$ _POST []接收? –
echo $ _POST ['qty'] ['your_ids'] ['your_quantity_get_here']; – JYoThI