In theory, I have two columns like so:
I want the result to be dog 6, and Elephant 2. What I have made so far (and failed [the amount does not get displayed]) is this:
$query_check_credentials = "SELECT word, SUM(amount) FROM Data Group By word";
$result = mysqli_query($dbc, $query_check_credentials);
while($row = mysqli_fetch_array( $result ))
{
echo $row['amount'];
}
You should give an alias to the sum:
SELECT word, SUM(amount) AS total_amount FROM Data GROUP BY word
and then use $row['total_amount']
.
If you don't do that, you have to use $row['SUM(amount)']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.