Re: currency out of postgresql
| From: | David Balatero | Date: | Fri, 14 Sep 2001 22:12:50 +0000 |
| Subject: | Re: currency out of postgresql | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-12464@lists.php.net to get a copy of this message | ||
I suppose you could just remove the $ and/or the comma with a regexp...
www.php.net/eregi_replace
-- David Balatero
----- Original Message -----
From: "Rick Eicher II" <rick@texol.net>
To: <php-db@lists.php.net>
Sent: Friday, September 14, 2001 3:00 PM
Subject: [PHP-DB] currency out of postgresql
> After I do the add $money comes out to be 0. The data comes out as $0 and
> $5,217.00, I need to add these two to get $5,217.00. How do you add money
> with the dollor sign in the data?
>
> rick
>
> -----Original Message-----
> From: Bas Jobsen [mailto:bas@startpunt.cc]
> Sent: Friday, September 14, 2001 7:24 AM
> To: Rick Eicher II
> Cc: php-db@lists.php.net
> Subject: Re: [PHP-DB] currency out of postgresql
>
>
> > $formatted = sprintf("%01.2f", $money);
> > printf ("<td align=\"center\">%01.2f</td></tr>\n",
> > $formatted);
>
> maybe twice, try:
> $formatted = sprintf("%01.2f", $money);
> echo "<td align=\"center\">$formatted</td></tr>\n";
>
>
> ----- Original Message -----
> From: "Rick Eicher II" <rick@texol.net>
> To: <php-db@lists.php.net>
> Sent: Friday, September 14, 2001 6:48 PM
> Subject: [PHP-DB] currency out of postgresql
>
>
> > I am trying to get two currency values from out of the database, add
them
> > together and print the to the screen. I am using the following code.
> >
> > $money = $myrow[6] + $myrow[7];
> > $formatted = sprintf("%01.2f", $money);
> > printf ("<td align=\"center\">%01.2f</td></tr>\n",
> > $formatted);
> >
> > $myrow[] is the array that I load the database records into.
> >
> > I can echo $myrow[6] & $myrow[7], which will show like $4.00 and
$4000.00.
> > But when I add them together the come out as 0 every time. The columns
in
> > the database are of type money. This is a postgresql database.
> >
> > Does any one see the errors of my ways?
> >
> > thanks,
> > Rick Eicher II
> > www.pbol.net
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-db-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>