如何在php [关闭]中打印mySQL sum()

I have this query and i am asking if i can print the result in PHP without saving the result in other table.

SELECT SUM(weekly_fees) FROM scout_cabs

You start by giving it an alias to output:

SELECT SUM(`weekly_fees`) AS `total` FROM `scout_cabs`

Then you parse it as any normal request via mysql.

<?php
$sql    = "SELECT SUM(`weekly_fees`) AS `total` FROM `scout_cabs`";
$run    = mysql_query($sql);
$result = mysql_fetch_assoc($run);
echo 'The sum of the query is: ' . number_format($result['total']);

It may also be worth looking into mysqli_ if you are not already using it, as mysql_ is now deprecated.