this is my code i want the sum of the fields but unable to do this any one can help in this regards
<?php
$hostname="localhost";
$username="root";
$password="";
$db = "usman";
$dbh = new PDO("mysql:host=$hostname;dbname=$db", $username, $password);
foreach($dbh->query("SELECT COUNT(*) as cnt
FROM ams
WHERE empid= {$_SESSION['sess_user_id']}
GROUP BY leavetype
HAVING leavetype =
sum('Absent'), sum('Annual'),sum('Medical'),
sum('Casual') , sum('LWOP') ") as $GrandTotal)
{
echo "<table ><tr ><td style='border: 0px; ' >" .
$GrandTotal['cnt'] . "</td></tr></table>";
echo "<br>";
}
?>
SUM(column)and notSUM('string'). dev.mysql.com/doc/refman/5.7/en/… and make sure you started the session.