Faqts : Computers : Programming : Languages : PHP : Database Backed Sites : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 26 people (19%) answered Yes
Recently 2 of 10 people (20%) answered Yes

Entry

How do I write a PHP script that would add up numbers in fields that go with certain Names in a mysql table?

Jul 17th, 2000 11:07
Matt Gregory, Rhyan Allen,


It is hard to tell what you are asking...
If you are asking how to add up numbers in numeric fields which 
correspond to names which you are using as keys in a table then your 
best bet is to do a select where clause with the name specified and 
then loop through the result set and add up the numbers in the fields.
If you are asking how do do something like adding up all the totals in 
field (i.e. SalesTax) then you could do a select all and iterate 
throughn the results totaling up the specified field.