I am building an inventory system for a client where there is a form used to enter in new inventory (made with chronoforms) and all the data is stored in a table. Then using chrono connectivity, I made a page to display the rows in the inventory table and even included a filter to filter results by one of the fields (model).
The client now want me to total three columns on the resulting table in the joomla site. I was able to implement to total using MySQL statements however there are a few issues I am having with it. First, if the value in the database for a dollar amount is 27,000 it won't total anything beyond the comma. If it is imputted in the table as 27000 the it totals fine. How can I get it to total with the value entered as 27,000 since visually this looks better. I don't mind if the value in the database is without the comma and we just format as currency on the view. Also, I want to have the totals recalculate when a filter is applied. Right now, the filter changes the number of records shown on the page but does not effect the totals calculated. The code I entered in the footer box of chronoconnectivity is below along with a screen shot of my page.
Thanks for the assistance,
Michael
[attachment=0]bovet stock.PNG[/attachment]
<?
$db =& JFactory::getDBO();
$query = "
SELECT SUM(`worldprice`) AS `total_worldprice`
FROM `jos_chronoforms_bovetstock1`;
";
$db->setQuery($query);
$total_worldprice = $db->loadResult();
echo "Total World Price = $".$total_worldprice;
?>
<br/>
<?
$db =& JFactory::getDBO();
$query = "
SELECT SUM(`cost`) AS `total_cost`
FROM `jos_chronoforms_bovetstock1`;
";
$db->setQuery($query);
$total_cost = $db->loadResult();
echo "Total Cost = $".$total_cost;
?>
<br/>
<?
$db =& JFactory::getDBO();
$query = "
SELECT SUM(`invoice`) AS `total_invoice`
FROM `jos_chronoforms_bovetstock1`;
";
$db->setQuery($query);
$total_invoice = $db->loadResult();
echo "Total Invoice = $".$total_invoice;
?>
The client now want me to total three columns on the resulting table in the joomla site. I was able to implement to total using MySQL statements however there are a few issues I am having with it. First, if the value in the database for a dollar amount is 27,000 it won't total anything beyond the comma. If it is imputted in the table as 27000 the it totals fine. How can I get it to total with the value entered as 27,000 since visually this looks better. I don't mind if the value in the database is without the comma and we just format as currency on the view. Also, I want to have the totals recalculate when a filter is applied. Right now, the filter changes the number of records shown on the page but does not effect the totals calculated. The code I entered in the footer box of chronoconnectivity is below along with a screen shot of my page.
Thanks for the assistance,
Michael
[attachment=0]bovet stock.PNG[/attachment]
<?
$db =& JFactory::getDBO();
$query = "
SELECT SUM(`worldprice`) AS `total_worldprice`
FROM `jos_chronoforms_bovetstock1`;
";
$db->setQuery($query);
$total_worldprice = $db->loadResult();
echo "Total World Price = $".$total_worldprice;
?>
<br/>
<?
$db =& JFactory::getDBO();
$query = "
SELECT SUM(`cost`) AS `total_cost`
FROM `jos_chronoforms_bovetstock1`;
";
$db->setQuery($query);
$total_cost = $db->loadResult();
echo "Total Cost = $".$total_cost;
?>
<br/>
<?
$db =& JFactory::getDBO();
$query = "
SELECT SUM(`invoice`) AS `total_invoice`
FROM `jos_chronoforms_bovetstock1`;
";
$db->setQuery($query);
$total_invoice = $db->loadResult();
echo "Total Invoice = $".$total_invoice;
?>