Reply to Re: how to stop variable rounding up after a division

Your name:

Reply:


Posted by mantrid on 10/08/06 00:29

Yes that was it
,'$price', works in the sql
whereas
,$price,
does not
thanks

"Colin Fine" <news@kindness.demon.co.uk> wrote in message
news:eg8too$agn$1$8300dec7@news.demon.co.uk...
> mantrid wrote:
> > I am trying to take an integer and divide it by 100 to give a decimal to
> > store in my database. The field in my mysql database is set to
decimal(4,2)
> > My php is
> > $price=number_format($price/100,2);
> > Ive also tried
> > $price=number_format($price,2)/100;
> >
> > but neither work it keeps rounding any value less than 100 to 1 whereas
I
> > want it to store the value to two DP
> >
> > eg
> >
> > 80 becomese 1 instead of 0.8
> > 180 becomes 2 instead of 1.8
> >
> > does anyone know how to do this?
> > Ian
> >
> >
> AFAICS, number_format should deliver a string, which is what a
> decimal(4,2) expects.
>
> I wonder if you are failing to quote the string in your SQL? It would be
> easier to tell if you posted the code.
>
> On thing to try is to print out $price after the number_format, to check
> whether the rounding happens then or later.
>
> Colin

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация