Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 8th, 2006, 04:34 PM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding the values within an array

Hey all!

was wondering if you could help me with my problem. I have the following code:

Function within a class file:

Code:
public static function getSomething($database){
    $query = "SELECT important FROM tblPurchases WHERE purchase = 3 AND buyer = 5";

    $result =  $database->Select($query);
    return $result;
  }


PHP Web Page:

Code:
$function= pFunction::getSomething($_DATABASE);

foreach($function as $result) {
$important = $result;

$count++;
}
This code counts the amount of records that match the SQL criteria and places the important variable into an array. However I would like to extract all values of "important" (which is an integer value) and add them together to produce a sum of all of the "important" values. Could somebody please advice me as to what I need to add to my code to acheive this.

Thanks

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I add up values in an array? Lucy Classic ASP Basics 6 May 31st, 2005 05:26 AM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM
Adding 2 values in a table Regornil JSP Basics 2 September 13th, 2004 02:32 AM
Adding Values NeilS21 Beginning VB 6 1 February 6th, 2004 10:45 AM



All times are GMT -4. The time now is 10:12 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.