title: How to add values to a single variable in while loop in php
body: <p>I would like to add the price values to a total_price and echo it. </p>
  
  <p>My code takes values from session and makes a mysql query to take information from database tables. Once I have it, it shows the prices of each row. Now I'm adding a total price, but instead of taking the values of all prices and add them, it takes the values of the last row only. I would like that total_price to add all the values $price.
  Here is the code: </p>
  
  <pre><code>&lt;?php 
  if (empty($_SESSION['cart'])) { echo "Nothing here";} else {
  $whereIn = implode(',', $_SESSION['cart']);
  
  $list_query = mysqli_query($con,"SELECT * FROM packages WHERE id IN ($whereIn)"); 
  while($run_list = mysqli_fetch_array($list_query)){
  $id = $run_list['id'];
      $price = $run_list['package_price'];  
      $title = $run_list['package_title'];  
  
  
      $total_price = '';
  $total_price += $price ;
  
  
  
  
  echo '&lt;p&gt; Product :',$title,' | Price: ',$price; ?&gt; &lt;a href="add_to_cart/remove_from_cart.php?id=&lt;?php echo $id; ?&gt;"&gt;Remove item&lt;/a&gt;&lt;/p&gt; 
  
  &lt;?php 
  
  }?&gt;  
  
  &lt;p&gt; Total Price: &lt;?php echo $total_price;?&gt;&lt;/p&gt;
  
  &lt;p&gt; &lt;button&gt; Checkout &lt;/button&gt;&lt;/p&gt;
  
  &lt;?php } ?&gt;
  </code></pre>