Re: [s2smedia] Adding numbers (math)
Hi,
You may be looking for something like this:
<?php
$totalCost = 0.00;
$listings = mysql_select('listings');
foreach ($listings as $listing) {
$totalCost += floatval($listing['cost']);
}
?>
This selects all the records form a section called "listings". It then loops through each record to total up the "cost" field and save it to a variable called $totalCost.
Note that the use of the mysql_select() function will only work if you're using CMSB Version 2.08 or above.
Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/