There is a request:
$res = mysqli_query($link, "SELECT sum(price) FROM items"); $sum=mysqli_fetch_assoc($res); echo ($sum); But he displays ARRAY. How do I get the sum of the numbers in the cell?
Or so
$res = mysqli_query($link, "SELECT sum(price) FROM items"); $row = mysqli_fetch_array($res); echo $row[0]; mysqli_fetch_array() works, then you don’t have to go with your allegations! Follow the link and read Выбирает одну строку из результирующего набора и помещает ее в ассоциативный массив, обычный массив или в оба - VismanWell, as a crutch option, I think it will do:
$res = mysqli_fetch_assoc(mysqli_query($link, "SELECT sum(price) sum_price FROM items")); echo $res['sum_price']; Source: https://ru.stackoverflow.com/questions/751281/
All Articles
echo ($sum['sum(price)'])- Alexander BelinskySELECT sum(price) as priceand get as $ sum ['price'] - Alexey Shimansky