I wrote this php code:
$query="SELECT post_hit FROM posts WHERE MONTH(post_date)=11 AND YEAR(post_date)=2016 AND post_hit>0 ";
$select_query= mysqli_query($connect, $query);
$post_hit= mysqli_fetch_all($select_query);
var_dump($post_hit);
echo array_sum($post_hit);
and the var dump result is the following:
C:\xampp\htdocs\newstheme\admin\admin.php:54:
array (size=6)
0 =>
array (size=1)
0 => string ‘8’ (length=1)
1 =>
array (size=1)
0 => string ‘9’ (length=1)
2 =>
array (size=1)
0 => string ‘1’ (length=1)
3 =>
array (size=1)
0 => string ‘3’ (length=1)
4 =>
array (size=1)
0 => string ‘10’ (length=2)
5 =>
array (size=1)
0 => string ‘64’ (length=2)
The problem is that the “echo array_sum($post_hit);” returns me the value of 0.What am i going wrong? I need to get the values from a specific column in my database and then to sum all these values.