i want solution for that

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
pankajkumar
Forum Newbie
Posts: 1
Joined: Sat Aug 01, 2015 10:34 am

i want solution for that

Post by pankajkumar »

Hi,
I want a solution for
Suppose there is a table called Emp in that there is 2 column
First column is emp name X,X,Y,Y and second column is salary
1000 ,2000,3000,4000.
Write a code to display sum of the same emp name ,
Like
X+X=3000,
Thank you
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: i want solution for that

Post by Christopher »

SELECT name, SUM(salary) AS total FROM Emp GROUP BY name
(#10850)
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: i want solution for that

Post by s.dot »

Christopher has provided an SQL solution. Assuming MySQL, displaying it in your web page would require usage of mysql_query(), and mysql_result() / mysql_fetch_assoc() / or mysql_fetch_array(). And then print()/echo your results in your web page or template.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply