bkbhatia
05-01-2007, 07:24 PM
I have made a calculator table name calculator. And fields are add1,add2,add3. I have made the sum formula Add1+add2+add3 as 'addtotal' in tableview.php to give the total of the values. But when we put values like 100.50+100.50+100.50 it give the toal 300 instead of 301.50. I have also tried format like format(add1+add2+add3,2) in tableview.php but it is still showing add values 300.00 instead of 301.50.
If any body can clarifies this problem, pl. clarify.
Another problem is that for sum of values of different two fields from two tables like if I have one table like fruits field applequantity and another table flower field flowerquantity like below:
Table1 fruits:
S.no Applequantities
1 -- 50
2 -- 45
3 -- 40
Table 2 Flowers:
S.No Flowerquantities
1. -- 56
2. -- 48
3 -- 67
Now I want to show results (Sums) of these two tables values in table 2 Flowers then what will be the php mysql code. I know the code for caculating only values for one table only which is as below.
mysql_select_db('abcd_Fruitsflowers');
$query = 'select * from Fruits';
$query2 = 'select SUM(Applequantities) AS qsum from Fruits';
$result = mysql_query($query);
$result2 = mysql_query($query2);
$num = mysql_num_rows($result);
$row = mysql_fetch_array($result2);
// echo '<strong>'.$num.'</strong>';
echo '<p>TotalAppleQuantities: ';
echo '<strong>'.$row['qsum'].'</strong>'; ?>
If any body can customize this code, pl. give the correct code to add values for these two tables two fields Then pl. give the code.
Thanks
B K Bhatia
If any body can clarifies this problem, pl. clarify.
Another problem is that for sum of values of different two fields from two tables like if I have one table like fruits field applequantity and another table flower field flowerquantity like below:
Table1 fruits:
S.no Applequantities
1 -- 50
2 -- 45
3 -- 40
Table 2 Flowers:
S.No Flowerquantities
1. -- 56
2. -- 48
3 -- 67
Now I want to show results (Sums) of these two tables values in table 2 Flowers then what will be the php mysql code. I know the code for caculating only values for one table only which is as below.
mysql_select_db('abcd_Fruitsflowers');
$query = 'select * from Fruits';
$query2 = 'select SUM(Applequantities) AS qsum from Fruits';
$result = mysql_query($query);
$result2 = mysql_query($query2);
$num = mysql_num_rows($result);
$row = mysql_fetch_array($result2);
// echo '<strong>'.$num.'</strong>';
echo '<p>TotalAppleQuantities: ';
echo '<strong>'.$row['qsum'].'</strong>'; ?>
If any body can customize this code, pl. give the correct code to add values for these two tables two fields Then pl. give the code.
Thanks
B K Bhatia