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.
$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);
Any help would be much appreciated.
Thanks!
Try this: