loop statement breaking
<p>please why is the loop statement breaking, after the multiplication it only update the last row, tried using a foreach loop for the $totalprice in the update statement it says invalid argument.</p>

<pre><code>if(array_key_exists('item', $_POST)){


// $items = $_POST['item'];
  //foreach($_POST['item'] as $item){
    //echo $item['Pquantity'] . ", ";
    //echo $item['Pidno'] . ", ";
   // }
    //Loop through $_POST items, updating the database for each item
    foreach ($_POST['item'] as $item) { 
        $Pquantity = intval($item['Pquantity']);
        $Pidno = ($item['Pidno']); 
        //echo $Pquantity . ", ";
        //echo $Pidno . ", ";
        //$totalprice = intval($item['Pquantity']) 
        $queryreg = mysql_query("
            UPDATE repplac
                 SET Pquantity = {$Pquantity}
                 WHERE
                       Pidno = '{$Pidno}'
                 AND
                       Uname = '{$_SESSION['username']}'
        ") or die(mysql_error());  

    }
    }
    $pplresult = mysql_query("SELECT * FROM repplac WHERE Uname = '{$_SESSION['username']}'") or die(mysql_error());
  while ($row = mysql_fetch_assoc($pplresult)) 
  {
  $totalprice = $row['Price'] * $row['Pquantity'];
  //echo "$totalprice";
  //die();
   $queryreg = mysql_query("
  UPDATE repplac
  SET Tprice = {$totalprice}
  WHERE
                       Pidno = '{$Pidno}'
                 AND
                       Uname = '{$_SESSION['username']}'
    ") or die(mysql_error());  
  }
</code></pre>
