calculate sum total of all the figures in a column

后端 未结 3 920
青春惊慌失措
青春惊慌失措 2020-12-22 10:46

\"table

I have a table that I want to calculate the sum total of all the values in column \"Price\"

3条回答
  •  忘掉有多难
    2020-12-22 11:17

    mysql_connect($hostname, $username, $password);
    mysql_select_db($db);
    
    $sql = "select sum(column) from table";
    $q = mysql_query($sql);
    $row = mysql_fetch_array($q);
    
    echo 'Sum: ' . $row[0];
    

    Replace variable names and table/column names as needed.

提交回复
热议问题