PHP While Loop: Second While Loop not showing data -


i'm having trouble on while loop. here code:

<?php //display's skill list $showitemlist = $con->query('select * 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) totalquantityinstock item_inventory_inhouse item_id="'.$row['item_id'].'"');               while($row = $showinhouseqty->fetch_assoc()) {                 echo $row['totalquantityinstock'];               }           echo '</td>';          echo '<td>';                  $showpharmaqty = $con->query('select sum(item_quantity) totalpharmaqty item_inventory_inpharmacy item_id="'.$row['item_id'].'"');               while($row = $showpharmaqty->fetch_assoc()) {                 echo $row['totalpharmaqty'];               }          echo '</td>';                                                                                                                               echo '</tr>';      }      }    ?> 

well, problem is, can't result of $row['totalpharmaqty'];

if use same variables in nested while loops in parent while loop, overwrite. change $row in second , third while loops $row2 , $row3 respectively, , should work fine.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -