Hello , Well i have a function whose aim is to get the sum of the field "Times" and return the value..I have implemented it as below.
function GetSumViewed($Category)
{include("dbinfo.inc.php");
$query="SELECT Times from mytable where name = 'people'";
$result=mysql_query($query);
$num=mysql_numrows($result);
if($num==0)
echo "No Records founds";
else
{$i=0;
$total=0;
while ($i < $num) {
$count=mysql_result($result,$i,"Times");
$total+=$count;
$i++;
}//while
}//else
echo $total;
mysql_close();
}
My Question is how can i avoid the while loop and use the SQL function SUM directly and assign it to a variable in php?
Thanks
regards
Mungra