首页 > 解决方案 > 从批次中选择下一个产品

问题描述

我有两个篮子。第一个篮子里有 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 } ?>

标签: php

解决方案


推荐阅读