php - 从批次中选择下一个产品
问题描述
我有两个篮子。第一个篮子里有 5 个芒果,第二个篮子里有 10 个芒果。如果需要的芒果少于 5 个,则从第一个篮子中挑选,否则如果需要的芒果超过 5 个,则从第一个篮子中挑选 5 个,然后从第二个篮子中挑选剩余的芒果。
下面的代码不起作用。
<?php
if (isset($_POST["check"])) {
$search = (htmlspecialchars(trim($_POST["search"])));
$quantty = $_POST["qtyy"];
$sql = "select * from stock where product_name=:product group by batch_no order by sn asc";
$stmt = $connectdb->prepare($sql);
$stmt->bindValue(':product', $search);
$stmt->execute();
$rresult = $stmt;
while($result=$stmt->fetch(PDO::FETCH_ASSOC)){
$next_batch_no =$result['batch_no'];
echo $next_batch_no;
$qt=$result["qty"];
echo $su;
if($qt<$quantty){?>
<div class="form-row">
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="form-group"><label for="username"><strong>Product
Name</strong></label><input class="form-control" type="text" placeholder="" value="<?php echo $result[" product_name"]; ?>"
name="productname" readonly></div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="form-group"><label for="username"><strong>Batch
No.</strong></label><input class="form-control" type="text" value="<?php echo $result[" batch_no"]; ?>"
name="batchno" readonly></div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="form-group"><label for="username"><strong>Mfg.
Date</strong></label><input class="form-control" type="text" value="<?php echo $result[" mfg"]; ?>"
name="mfgdate" readonly></div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="form-group"><label for="username"><strong>Exp.
Date</strong></label><input class="form-control" type="text" value="<?php echo $result[" exp"]; ?>"
name="expdate" readonly></div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="form-group"><label for="username"><strong>Quantity
</strong></label><input class="form-control" value="equal or greater" type="text" name="qtty" readonly>
</div>
</div>
</div>
<?php }elseif($qt>=$quantty){?>
<div class="form-row">
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="form-group"><label for="username"><strong>Product
Name</strong></label><input class="form-control" type="text" placeholder="" value="<?php echo $result[" product_name"]; ?>"
name="productname" readonly></div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="form-group"><label for="username"><strong>Batch
No.</strong></label><input class="form-control" type="text" value="<?php echo $result[" batch_no"]; ?>"
name="batchno" readonly></div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="form-group"><label for="username"><strong>Mfg.
Date</strong></label><input class="form-control" type="text" value="<?php echo $result[" mfg"]; ?>"
name="mfgdate" readonly></div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="form-group"><label for="username"><strong>Exp.
Date</strong></label><input class="form-control" type="text" value="<?php echo $result[" exp"]; ?>"
name="expdate" readonly></div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="form-group"><label for="username"><strong>Quantity
</strong></label><input class="form-control" type="text" name="qty" value="b" value="" readonly></div>
</div>
</div>
<?php break;}?>
<?php }?>
<?php } ?>
解决方案
推荐阅读
- html5-canvas - Canvas/WebGL 2D tilemap 网格工件
- python - 在第二列中每个匹配项的一个 DataFrame 列中查找索引
- mysql - 使用变量时sql语句慢
- rust - 生锈寿命说明符的问题
- javascript - Javascript mouseover 运行函数,然后等待并再次运行
- python - 如何在pygame pan中逐个字母地制作文本?
- javascript - 如何在jgrasp中使用circle类
- ffmpeg - 在 ffmpeg 中使用 Mjpeg 编解码器创建 4K 视频
- python - numpy 数组能够为大型数组分配大量内存
- c# - 按大小 C# 对所有文件和文件夹进行排序