I want to calculate sub total and totals from mysql table data. How can i do that in php script. can any one guide me ???
What have you tried do far? Show us your code.
Some logic would be nice too. We can’t read your homework assignment paper I mean requirements from your brain.
What’s the difference between the subtotal and total? What factors are you applying? Whats the structure of your tables?
MYSQL querry
Select id, name, marks
from table
(sum of marks need to calculated on the basis of name )
This is my my desired out
id Name marks
1 Umar 50
2 UMar 50
SUb Total 100
3 Ali 50
4 Ali 50
Sub Tot 100
GRand Total 400
Unless you need the individual mark values elsewhere in the page, GROUP BY and SUM your query to get the subtotals.
Then use PHP to walk through the results, and accumulate the grand total.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.