On Tue, 21 Nov 2000, Gustavo Souza wrote:
SELECT SUM() dont work for me cause the fields have (R$) 300.00
and not only the numbers ....
i need to do it on php ...
thanks
GS
You should consider changing your database structure; there is no need to
store the currency symbol for every record, and it is only needed when you
want to display the values, so you can just echo it in front of the
relevant result. Using the SUM function in SQL is a great deal faster than
performing the calculation using a loop in PHP; as the size of your DB gets
larger, this has the potential to become a slow process.
But if you absolutely insist, recheck your value that is returned by
$price = substr ("$fullprice", 3);
Sir,
Storing the currency in a numeric column is much, much better than computing the sum in PHP. You can also do the sum in MySQL without altering the table, although this is still inferior to changing the table structure. Use
SELECT Sum(Right(currency, Length(currency) - 5)
if you have 5 characters (including the blank) in front of the number part of the string.
Bob Hall
Know thyself? Absurd direction!
Bubbles bear no introspection. -Khushhal Khan Khatak