【发布时间】:2018-04-10 12:45:50
【问题描述】:
我创建了一个页面来生成发票。我正在使用 php 从数据库中获取产品数据。现在,当我尝试生成发票并使用复选框选择一些产品时。它只给我选定复选框的值,即“产品名称”,但它没有给我包含其价格和数量等的相关复选框的值。以下是我的代码:-
<?php
$query = mysqli_query($conn, "SELECT * from products order by product_name asc");
while ($row = mysqli_fetch_array($query))
{
$product_id = $row['product_id'];
$product_name = $row['product_name'];
echo "<tr>
<td><input type='checkbox' name='product_id[]' value='$product_id'> $product_name</td>
<td><input type='text' name='product_ref[]' class='form-control'></td>
<td width='2%'></td>
<td><input type='text' name='quantity[]' class='form-control'></td>
<td width='2%'></td>
<td><input type='text' name='unit_price[]' class='form-control'></td>
</tr>";
【问题讨论】:
-
您的帖子中有很多代码,如果需要,请考虑将其删减以创建一个包含硬编码数据的最小示例。
-
看,这是从数据库中检索产品的代码。当我尝试选择特定产品时,它没有给我数量和单价等值。
-
你完全忽略了我的评论,好像你从来没有理解过一样。
-
$product_name tr> -
对不起,我在这里发布了小代码。但代码格式不正确。