title: PHP: summation needed inside of a loop
body: <p>The student is back. Thanks for you help an patience ;) </p>
  
  <p>I'm using a foreach loop like this: </p>
  
  <pre><code>foreach ($value as $val)
  {
  //coming from database, from a select query:
  $points = $row['points'];  
  
  //now I want to update another database table:  
   $sql = "update user set totalpoints=".$points." where userid=".$uid." ";
  
  //but by doing this, table user is updated with the value of $points in the last iterarion 
  
  }
  </code></pre>
  
  <p>What do I have to do to update my table with the summation of $points and not with the value of the last iteration? </p>
  
  <p>Thanks again </p>