Jump to content


Photo

Adding Numbers with PHP and MySQL


  • Please log in to reply
3 replies to this topic

#1 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 31 May 2006 - 11:02 AM

Hello,

I haven't coded in PHP in a long time.. good to be back. I have a question.. I own a game site, www.buzzingames.com. In it, it keeps record of the amount of games played each day. How do I select the data from them and ADD the numbers up?


[img src=\"http://img.photobucket.com/albums/v216/lpxxfaintxx/phphelp.jpg\" border=\"0\" alt=\"IPB Image\" /]

Regards

#2 appeland

appeland
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 31 May 2006 - 11:40 AM

Hello,

you may use

SELECT SUM(GamesPlayed) FROM gamestoday

Cheers,
Andi

#3 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 01 June 2006 - 02:11 AM

How will I echo out the results?

#4 samshel

samshel
  • Members
  • PipPipPip
  • Advanced Member
  • 837 posts

Posted 01 June 2006 - 11:05 AM

$result = mysql_query("SELECT SUM(GamesPlayed) as total_plays FROM gamestoday");

$row = mysql_fetch_array($result);
echo $row['total_plays'];


Cheers,
SamShel
-----------------------------------------------
--: FUTURE IS LINUX :--
-----------------------------------------------




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users