It’s best if you used an alias for your SUM:
SELECT SUM(`field`) as `sum` FROM `table_name`
And then, you’ll be able to fetch the result normally by accessing the first result row’s $row['sum']
.
More Related Contents:
- About how does mysqli_query() Function and mysqli_fetch_array($result) work?
- Can I mix MySQL APIs in PHP?
- How to change mysql to mysqli?
- Best way to INSERT many values in mysqli?
- Call to a member function bind_param() on a non-object [duplicate]
- How to use mysqli prepared statements?
- MySQLi prepared statements error reporting [duplicate]
- How can I get an unknown username given an ID?
- mysqli last insert id
- Build SELECT query with dynamic number of LIKE conditions as a mysqli prepared statement
- mysqli_query() expects parameter 1 to be mysqli, object given
- MySQLi count(*) always returns 1
- Warning: mysqli_connect(): (HY000/2002): No such file or directory
- Use one bind_param() with variable number of input vars
- Using Mysqli bind_param with date and time columns?
- PHP UPDATE prepared statement
- Using MySQLi from another class in PHP
- SELECT * FROM in MySQLi
- MySQLI binding params using call_user_func_array
- Mysqli fetch_assoc vs fetch_array
- Mysqli throws “Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given” [duplicate]
- Is mysqli extension enabled in this php configuration?
- php warning: mysqli_close() expects parameter 1 to be mysqli
- Getting error mysqli::real_connect(): (HY000/2002): No such file or directory when I try to access my project on live server [duplicate]
- Get number of rows matched by UPDATE query with PHP mysqli
- How to use mysqli_query() in PHP?
- mysqli_fetch_array returning only one result
- mysqli persistent connection
- Create mysql trigger via PHP?
- Cannot figure out how to run a mysqli_multi_query and use the results from the last query