PHP While循环:第二个While循环不显示数据

PHP While循环:第二个While循环不显示数据,php,while-loop,Php,While Loop,我在While循环中遇到问题。这是我的密码: <?php //DISPLAY'S SKILL LIST $showItemList = $con->query('SELECT * FROM items'); if ($showItemList->num_rows > 0) { $x=1; // output data of each row while($row = $showItemList->fetch_assoc()) {

我在While循环中遇到问题。这是我的密码:

<?php
//DISPLAY'S SKILL LIST
$showItemList = $con->query('SELECT * FROM items');


if ($showItemList->num_rows > 0) {
     $x=1;
     // output data of each row
     while($row = $showItemList->fetch_assoc()) {
         echo '<tr>';
         echo '<td>' . $x++ . '</td>';
         echo '<td>' . $row['item_id'] . '</td>';
         echo '<td>' . $row['item_name'] . '</td>';
         echo '<td>' . $row['item_category'] . '</td>';
         echo '<td>' . $row['item_costprice'] . '</td>';
         echo '<td>' . $row['item_retailprice'] . '</td>';
         echo '<td>' . $row['item_tax'] . '%</td>';
         echo '<td>';
              $showInHouseQty = $con->query('SELECT SUM(item_quantity) AS TotalQuantityInStock FROM item_inventory_inhouse WHERE item_id="'.$row['item_id'].'"');
              while($row = $showInHouseQty->fetch_assoc()) {
                echo $row['TotalQuantityInStock'];
              } 
         echo '</td>';
         echo '<td>'; 
                $showPharmaQty = $con->query('SELECT SUM(item_quantity) AS TotalPharmaQty FROM item_inventory_inpharmacy WHERE item_id="'.$row['item_id'].'"');
              while($row = $showPharmaQty->fetch_assoc()) {
                echo $row['TotalPharmaQty'];
              }
         echo '</td>';                                                                                                                     
         echo '</tr>';
     }     
} 


?>

如果在嵌套while循环中使用与父while循环中相同的变量,它们将被覆盖。在第二和第三行中更改
$row
,同时分别循环到
$row2
$row3
,应该可以正常工作。

第二个查询可以工作吗?覆盖
$row
两次,更改该值谢谢!我非常感谢你的回答。解决了我的问题。