Topic: issue with number_format function (Read 1512 times)
Sandwich Artist
Posts: 25
186 credits Members referred : 0
« on: Jun 19, 2008, 07:46:17 pm »
Basically when I have a number that is an even thousand such as 1000 or 5000, they get displayed using the number_format as 1,000.00 or 5,000.00 for presentation, the problem is that when the user saves the values end up getting saved as 1 and 5 respectively. I know that its something wrong with the number_format function itself, but now sure how to get around this and still be able to display the values with the proper formatting. Any ideas? Thanks in advance for any help.
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6691
34714 credits Members referred : 374
It's time to use PHP5!
« Reply #1 on: Jun 20, 2008, 07:57:46 am »
you need to convert the number back to 1000.00 or 1000 before you store the value in your database. use number_format only for presentation
Sandwich Artist
Posts: 25
186 credits Members referred : 0
« Reply #2 on: Jun 25, 2008, 09:43:16 pm »
the problem is that there are nearly 100 values on the page and I never know which ones may get entered as an even 1000 so I'm not sure how to check and see if the value needs to be multiplied by 1000 before saving.
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6691
34714 credits Members referred : 374
It's time to use PHP5!
« Reply #3 on: Jun 25, 2008, 10:26:58 pm »
You need some fuinction to check the size of the number, check the php manual I'm sure I saw some there
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7792