Jump to content


Photo

**SOLVED** PHP Calculation Help Please


  • Please log in to reply
4 replies to this topic

#1 adamjnz

adamjnz
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 10 April 2006 - 11:31 AM

Is it possible to use PHP to sum some numbers for a table column?

I am using dreamweavers "repeat region" feature to give a line total for each record in a db table. The line total isn't stored in the database it is calulated on the page.

Is there a way to add a total at the the bottom of the column or am I trying to do the impossible?


#2 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 10 April 2006 - 11:54 AM

Not in PHP but I believe the MySQL call you want is something like this:
$query=mysql_query("SELECT SUM(totals) FROM scores WHERE `player`='alive'");

Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#3 adamjnz

adamjnz
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 10 April 2006 - 11:58 AM

[!--quoteo(post=363271:date=Apr 10 2006, 11:54 PM:name=Yesideez)--][div class=\'quotetop\']QUOTE(Yesideez @ Apr 10 2006, 11:54 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Not in PHP but I believe the MySQL call you want is something like this:
$query=mysql_query("SELECT SUM(totals) FROM scores WHERE `player`='alive'");
[/quote]

But the values I want to sum arent in the DB, they are calculated by PHP on the actual page

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 10 April 2006 - 02:59 PM

Can you post the code as it exists now?

Ken

#5 adamjnz

adamjnz
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 11 April 2006 - 12:44 AM

[!--quoteo(post=363305:date=Apr 11 2006, 02:59 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 11 2006, 02:59 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Can you post the code as it exists now?

Ken
[/quote]

Thanks but I have worked it out now




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users