Problem using SUM / mysqli::num_rows()
Posted: Thu Aug 02, 2007 6:48 pm
Can anyone please explain why this doesn't return the sum of the values stored in "price"...
When I use that code I get:
Fatal error: Call to undefined method mysqli::num_rows()
All help is greatly appreciated. Thanks in advance
[/syntax]
Code: Select all
// Compute total spent
$sql = "SELECT SUM(price) AS total FROM purchase";
if ($result = $mysqli->query($sql)) {
if ($mysqli->num_rows()) {
$row = $result->fetch_assoc();
echo $row['total'];
}
} else {
echo $mysqli->error;Fatal error: Call to undefined method mysqli::num_rows()
All help is greatly appreciated. Thanks in advance
[/syntax]