title: PHP Inserts only the first row
body: <p>This PHP code only inserts the first row then returns an error: Call to a member function fetch_assoc() on a non-object.
  Please Help.</p>
  
  <pre><code>$sqlquery = "SELECT * FROM shopcart WHERE UserID='$Useremail'";
      if(!$result = $db-&gt;query($sqlquery)) die ('Error getting Food Information ['.$db-&gt;connect_error.']');
      $result = $db-&gt;query($sqlquery);
  
      while($row = $result-&gt;fetch_assoc()){
          //echo $row['name'];
          $name= $row['name'];
          $productid = $row['ProductID'];
          $initialPrice = $row['InitialPrice'];
          $qty = $row['Quantity'];
  
  
  
          //insert into to ordereditems
          $sql = "INSERT INTO ordereditems (OrderID, ProductName, ProductID, Quantity, SalesPrice) 
          VALUES ('$orderid', '$name', '$productid','$qty','$initialPrice')";
          if(!$result = $db-&gt;query($sql)) die('There was an error Processing Order Again [' . $db-&gt;error . ']');
  
      }
  </code></pre>