是否有一个简单的函数来计算和输出PHP中的几个列值[关闭]

I have an application connected to a database. Now I want to add the values from several columns of several datasets together

I tried with the SUM()-Function but i don't know how to spend the values so that they are visible in the application.

I have no idea how to build the code smart.

it should be like this:

$sql = "SELECT SUM(column1)+(column2)";

echo $Sum of all columns and datasets.

I have now following code:

 $sql = " SELECT
   SUM(ps_asyl_oberteil) as 'ps_asyl_oberteil',
   SUM(ps_asyl_unterteil) as 'ps_asyl_unterteil',
   SUM(ps_asyl_jacke) as 'ps_asyl_jacke',
   (SUM(ps_asyl_oberteil) + SUM(ps_asyl_unterteil) + SUM(ps_asyl_jacke)) as 'Total'
  FROM ps_asyl";

  Line 20: echo $result->Total;

and I receive the following error message:

Notice: Undefined variable: result in /opt/lampp/htdocs/lab/asylanten_detail.php on line 20

Notice: Trying to get property 'Total' of non-object in /opt/lampp/htdocs/lab/asylanten_detail.php on line 20

It is easy:

SELECT 
   (column1 + column2 + column3) as 'Total'
FROM table;

Or if you want to output as one row:

SELECT 
   SUM(column1) as 'column1',
   SUM(column2) as 'column2',
   SUM(column3) as 'column3',
   (SUM(column1) + SUM(column2) + SUM(column3)) as 'Total'
FROM table;

Hope it helps!