I am trying to add numbers located in my database. so I tried sum() in SQL but it didn't show the total number. I don't know whats wrong with my code.
This is my code
<?php
session_start();
$email = $_SESSION['login_user'];
$con = mysqli_connect("localhost" , "root" , "" , "db_name");
if (mysqli_connect_errno()) {
echo "failed to connect:" . mysqli_connect_error();
}
$sql = "SELECT SUM(points) FROM points WHERE email='$email '";
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_array($result, MYSQLI_NUM);
echo $row[0]. "total number" ;
mysqli_free_result($result);
mysqli_close($con);
?>
it just shows total number. i don't know what is wrong here