title: Sum the total of a column and save as a variable
body: <p>Trying to sum the total of a column and save as a variable.
  The query has worked as I have tested it with PHPMyAdmin.  Just struggling to save the figure received from the query into a variable.  </p>
  
  <pre><code> $con = mysql_connect(DB_HOST, DB_USER, DB_PASS);
   if (!$con)
     {
     die('Could not connect: ' . mysql_error());
     }
  
   mysql_select_db(DB_NAME, $con);
  
   $result = mysql_query("SELECT SUM(column_name) FROM tablename");
  
  
  
    mysql_close($con);  
  </code></pre>
  
  <p>Any help would be much appreciated.  </p>
  
  <p>Thanks!</p>