首页 > 解决方案 > 表中重复项记录显示

问题描述

在下面的代码中,我试图显示靠近 ReOrder-Point 或不足的项目的项目。
所有的 ReOrder-Point 都是加 5。
在书中的 Item 它应该是 6+5=11 它应该
在铅笔列表中它应该是 5+5=10 因为它有更多的数量它不属于不足的列表项目

样品表项目:

| ID | Item name | Quantity | ReOrder-Point |
| 1 | book | 11 | 6|
| 2 | pencil | 25 | 5|
| 3 | shoe | 4 | 5|
| 4 | watch | 20 | 10|

    <?php
     include("connection/mysqlconnect.php");
     $sql="SELECT * FROM items";
     $result = $conn->query($sql);
       while($row = mysqli_fetch_array($result)) {
       $Item_Name = $row ['Item_Name'];
       $Stock_No = $row ['Stock_No'];
       $Description = $row ['Description'];
       $Quantity = $row ['Quantity'];
       $ReOrder_Point = $row ['ReOrder_Point'];

     $false_ReOrderP = $ReOrder_Point + 5;

      if ($Quantity <= $false_ReOrderP) {
        $rItem_Name = $Item_Name;
        $rStock_No = $Stock_No;
        $rDescription = $Description;
        $rQuantity = $Quantity;
        $rReOrder_Point = $ReOrder_Point;
     } else { 
           //nothing
      }
     ?>

这就是它显示的内容。它是否重复取决于我的 Items 表中有多少行
| ID | Item name | Quantity | ReOrder-Point |
| 1 | book | 11 | 6|
| 1 | book | 11 | 6|
| 3 | shoe | 4 | 5|
| 3 | shoe | 4 | 5|


| ID | Item name | Quantity | ReOrder-Point |
| 1 | book | 11 | 6|
| 3 | shoe | 4 | 5|

如果我用这个解决了我的问题,那么预期的表格结果。
如果有人有与我相同的查询条件,请随时分析:)
$sql1="SELECT * FROM items WHERE Quantity <= (ReOrder_Point + 5)"

标签: php

解决方案


推荐阅读