MySQL/PHP Question

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
atomix
Forum Newbie
Posts: 3
Joined: Tue Oct 07, 2003 4:27 am

MySQL/PHP Question

Post by atomix »

ok say that i have a column in my table that has a list of download counts, how would i make a php/mysql query to count up all the numbers for each row into 1 full number aka the total download count?
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

It depends if you just want to know how many records :

Code: Select all

SELECT COUNT(*) FROM table_name WHERE ....
or if you have values on each record that you want to total up :

Code: Select all

SELECT SUM(*) FROM table_name WHERE ....
then add on your WHERE clause to limit it to the specific details you want or leave it off for all the records.
atomix
Forum Newbie
Posts: 3
Joined: Tue Oct 07, 2003 4:27 am

Post by atomix »

thanks so much :D
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

If you read these two tutorials I am sure you will find out that there are many other things you can do with mySQL that could simplify your life in the future.

http://www.devshed.com/Server_Side/MySQL/Speak/
Post Reply