title: Displaying a running total on my website?
body: <p>I'm having a little trouble working out how to display a running total of sales that have gone through my website.  I have no problem working out how to do this with a single output from one table, but unfortunately for my website the results of total sales are spread across 2 tables in the database.</p>
  
  <p>I normally get the total sales manually using a Union query in SQL (whenever I feel like checking it).  I am trying to devise a means of displaying the total figure on my website as a single number formatted with comma's for thousands.</p>
  
  <p>So far I have managed to create some code which displays the total's from each table as a separate figure.  Apart from the 2 separate figures, this is perfect.  All I need to do is join up the 2 rows of output into a single figure.  The code I currently have is below:</p>
  
  <pre><code>$sql= "SELECT sum(price) AS total_price FROM `table_A` 
  UNION ALL
  SELECT sum(price) AS total_price FROM `table_B`";
  $res= mysql_query($sql);
  if (mysql_num_rows($res)&gt;0) {
    while ($row=mysql_fetch_array($res)) {
  echo '&lt;h3&gt;'.number_format($row["total_price"], 0).'&lt;/h3&gt;';
    };
  };
  echo mysql_error();
  </code></pre>
  
  <p>Can anyone help me with this problem?</p>