how to add and multiply all the numbers that stored in my database?.. huhu.. i need it asap huhu..

Recommended Answers

All 2 Replies

use a while loop function.could you post your code or the field that will be added or multiplied so that I can helpm you better?thanks

I'll give you an example:

<?php
$query="Select field from table";
$result=mysql_query($query);
$num=mysql_num_rows($result);
$i=0;
$total=0;
while ($i<$num)
{
$field=mysql_result($result,$i,"field");
$total=$total + $field;
$i++;
}
echo $total;
?>

get it?
if you want the numbers to be multiplied then change the "+" sign to "*".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.