例如,有一个客户购买了4个“产品一”。并且它已被插入到表中。
产品表:
---------------------------------- Product quantity ---------------------------------- Product-One 4
当客户购买该产品时,他们当时还没有决定要购买该产品。他们只想和我们一起保存。第二天,当客户需要产品时,他们要求我们交付产品。
由于他们购买了4个PRoduct-One,因此他们可以选择希望我们将其交付给他们的产品数量。
现在我不知道如何打破数量,例如在product-中,有4个数量的人在下拉选择中变成1,2,3,4。
<select> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <select>
请有人帮我。对我来说,这变得越来越复杂。:/
这是我的模糊PHP代码:
<table id="canvasEstockTable"> <tr> <td>Product</td> <td>Quantity</td> <td>Pick</td> </tr> <?php $resultsTicket = $mysqli->query("SELECT * FROM order_history WHERE member_name = '$member_name' ORDER BY id ASC"); if ($resultsTicket > 0) { while($obj = $resultsTicket->fetch_object()) { echo' <tr> <td>$obj->product_name</td> <td>$obj->quantity</td> <td> <select name="quantity" required> <option value="">Choose Quantity</option> //IT SHOULD BE LOOPING AUTOMATICALLY HERE// <option value="{$Quantity_1}">'.{$Quantity_1}.'</option> <option value="{$Quantity_2}">'.{$Quantity_2}.'</option> <option value="{$Quantity_3}">'.{$Quantity_3}.'</option> <option value="{$Quantity_4}">'.{$Quantity_4}.'</option> </select> </td> </tr>'; } } ?> </table>
[在这里更新]
<?php $resultsTicket = $mysqli->query("SELECT * FROM orders_history WHERE customer_name = '$member_name' ORDER BY id ASC"); if ($resultsTicket > 0) { while($obj = $resultsTicket->fetch_object()) { echo' <tr> <td>'.$obj->items.'</td> <td>'.$obj->quantity.'</td> <td> <select name="quantity" required> <option value="">Choose Quantity</option> for ($q = 1; $q <= $obj->quantity; $q++) { <option value="'.$q.'">'.$q.'</option> } </select> </td> </tr>'; } }
一个简单的for循环:
<?php $resultsTicket = $mysqli->query("SELECT * FROM order_history WHERE member_name = '$member_name' ORDER BY id ASC"); if ($resultsTicket > 0) { while($obj = $resultsTicket->fetch_object()) { ?> <tr> <select name="quantity" required> <option value="">Choose Quantity</option> <?php for ($q = 1; $q <= $obj->quantity; $q++) { ?> <option value="<?=$q?>">Quantity <?=$q?></option> <?php } ?> </select> </tr> <?php } %>