Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add up sales for a person 1

Status
Not open for further replies.

deecee

Technical User
Aug 25, 2001
1,678
US
I have a dbase where Salespeople enter in their sales (php) off a website and their sales are tracked by their salesrepid.

Their salesrepid is also their username. I havent even been able to come close and since my php knowledge is about 0 then ideally if you could point me to a tutorial that would help would be great (not php.net -- that is was to technical).

I would like to know how to set up a funciton to add all sales by salesrepid -- so joe schmo with salesrepid of A0023454 enters. I would like all his sales tallied up after he logs in. I tried passing on his Username which is stored in a session variable but i cannot get a sum.

I can add $a + $b but how do i add all values associated with $salesrepid.

zzzzzz
 
Insufficient data for a meaningful answer.

For example, you mention that your data is in a database...what database? MySQL? Access?

This could make a difference in how to do it.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
MySql dbase

just to clarify -- i want all sales under 1 salesperson to be added up and displayed -- i can display each individual sale but how would i sum them up -- some sales people will have 1 sale some 4 etc.

zzzzzz
 
I'd just ask MySQL to do it for me.

I would pass it a query like:

SELECT SUM(salescolumnname) AS totalsales FROM salestablename WHERE salesmancolumnname = [salesman's number]

MySQL will return a single value -- the total sales for that salesman.

There is good example code at the PHP online manual entries for mysql_fetch_assoc() and mysql_fetch_array() which demonstrate how to write a script which interacts with MySQL. See also the FAQ in this forum: faq434-3850.





Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top