Hi everyone
Don't know if someone can help me with my problem.
I'm trying to get a total from a loop variable name($cost), I'm running a for loop, thats getting values from mysql, all that i need is for the $cost value to be added up.
Code example:
$sql="select * from table";
$result=mysql_query($sql)or die(mysql_error());
$rows=mysql_num_rows($result)or die(mysql_error());
for($i=0; $i<$rows; $i++){
$calld=mysql_result($result, $i, 'calldate');
$dst=mysql_result($result, $i, 'dst');
$duration=mysql_result($result, $i, 'duration');
$todescr=mysql_result($result, $i, 'ToDescr');
$cost=mysql_result($result, $i, 'CallCost');
}
Give's this in output.
Date Time Dailed Number Location AccCode Duration Cost
2008-05-05 08:47:48 0126747276 Pta 6600 00:00:33 R 0.32
2008-05-05 09:44:55 0798823159 Vodacom 6600 00:00:42 R 1.31
2008-05-05 09:49:08 0798823159 Vodacom 6600 00:01:07 R 2.09
2008-05-05 09:52:35 0825217925 Vodacom 6600 00:00:22 R 0.69
2008-05-05 10:06:45 0732430995 Mtn 6600 00:00:46 R 1.43