It's been a while since I had to do anything like this and I'm at a road block.
Here's the scenario...
I have a DB column (original_cost) which contains numbers with or without a dollar sign. I need to be able to perform some math (sum, averages, etc) on this column.
I have pulled the data out into an array so that it could formatted on the screen...
while ($row=mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '<tr>';
echo '<td><input type=checkbox></td>';
echo '<td>'.$row['po_number'].'</td>';
echo '<td>'.$row['description'].'</td>';
echo '<td>'.$row['vendor_name'].'</td>';
echo '<td>'.$row['original_cost'].'</td>';
echo '<td>'.$row['fund'].'</td>';
echo '<td>'.$row['program'].'</td>';
echo '<td>'.$row['object_code'].'</td>';
echo '</tr>';
}
I then use ereg_replace to get rid of the dollar signs....
$clean_cost=ereg_replace('\\$', '', $row['original_cost']);
But I'm at a loss on how to totall up all the clean costs to get a total cost. Any help is much appreciated.
Thanks,
Scott