PHP CODE

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thomasvt28
Forum Newbie
Posts: 10
Joined: Tue Aug 05, 2014 4:02 am

PHP CODE

Post by thomasvt28 »

ID CUSTOMER_ID WEEK_NO TOTAL

1 100 31 100
2 101 31 150
3 100 31 400


My table like above,...i need to take add total,if the customer id and week period is same..how to do this..?

Customer_id 100=500 & Customer_id 101=150..(i need result like this))

please do help/...please fast
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP CODE

Post by Celauran »

We're not doing your homework for you. What have you tried? What errors are you encountering?
thomasvt28
Forum Newbie
Posts: 10
Joined: Tue Aug 05, 2014 4:02 am

Re: PHP CODE

Post by thomasvt28 »

used group by to select from database but it returns last row only
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP CODE

Post by Celauran »

GROUP BY is the correct approach, but it should return two rows. What's your exact query?
thomasvt28
Forum Newbie
Posts: 10
Joined: Tue Aug 05, 2014 4:02 am

Re: PHP CODE

Post by thomasvt28 »

Got answer
Post Reply