i won't give you complete examples because i am not going to write this for you. what you want to do is query the database for what you want. then as you cycle through your result, build your table. (ie. get one field of the query, wrap it in a cell, move to the next...) as you are bulding your table, whenever you get the the field you want to add, shove it into an array. then when you want to get the total, add the array values. here are some places to go:
http://www.php.net/mysql
http://www.php.net/while
http://www.php.net/array-sum
keep all that stuff in mind while you look through the functions. building the table will be the hardest, but it actually isn't to tough a task.