php fetch_assoc只显示多行相同的行

时间:2017-07-13 21:45:12

标签: php mysql mysqli fetch

我希望以下代码的查询结果包含两行具有完全相同的值,但它只显示这两行的一行,其他行正确显示,当我在db中运行它时,查询正常工作。我找到的解决方案是在select查询中添加唯一ID但我想知道为什么php跳过一行。

 $queryitem=$newconn->query("select productname, qty from table where condition");
 $result=array();
 $count=0;
 while ($item=$queryitem->fetch_assoc()){
    $result[$count]=$item;
    $count+=1;
 }

期望结果(查询结果显示在db中):

      productname    qty
      aaa             10
      aaa             10
      bbb              5

Fecth结果:

          productname    qty
          aaa             10
          bbb              5

0 个答案:

没有答案