Query to add does not give me the result

0

I'm trying to add the amounts of a column, I have this query, but when I show it on the Web it does not show me the result.

<td>
<?php 
  $query = mysqli_query ("SELECT SUM(importe_total) FROM consumobar"); 
  $result =  mysqli_fetch_assoc ($query); 
  echo "<p>$result</p>"; 
?>
</td>
    
asked by user5406 30.10.2017 в 18:00
source

1 answer

1

You must use mysqli_query delivering two parameters:

mysqli_query($conexion, $query);

Otherwise $ result is an array:

 while ($row = mysqli_fetch_assoc($resultado)) {
       echo $row["Name"];
    }

You can use var_dump to visualize the structure of the array that throws you.

    
answered by 30.10.2017 в 18:02