NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Money values in MySQL

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
2 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 07-29-2005, 04:11 AM THREAD STARTER               #1 (permalink)
Senior Member
 
Porte's Avatar
Join Date: May 2005
Location: I'm right here
Posts: 3,525
Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of
 



Money values in MySQL


Hello,

What's the best method to store money values in a mysql?
Float, double..or what? varchar doesn't work because I'll need to sort values by order some times. How can you store the value as the following format: x,xxx.xx not just xxx.xx

Thank you,
-Ahmed
__________________
WP Theme Developer
Your One-stop for Premium Magazine/CMS WordPress Themes
Deluxe Themes
Porte is offline  
Old 07-29-2005, 04:43 AM   #2 (permalink)
NamePros Member
 
Icespadez's Avatar
Join Date: Apr 2005
Location: Boston, MA
Posts: 26
Icespadez is an unknown quantity at this point
 



For money values I use a float. When the result is returned from a query you can format as you need.
Icespadez is offline  
Old 07-29-2005, 05:10 AM THREAD STARTER               #3 (permalink)
Senior Member
 
Porte's Avatar
Join Date: May 2005
Location: I'm right here
Posts: 3,525
Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of
 



Ah, so its possible to convert x,xxx.00 to xxxx.00 and xxxx.00 to x,xxx.00? What function can do this? I'm using php.
__________________
WP Theme Developer
Your One-stop for Premium Magazine/CMS WordPress Themes
Deluxe Themes
Porte is offline  
Old 07-29-2005, 09:20 AM   #4 (permalink)
Account Suspended
 
axilant's Avatar
Join Date: May 2004
Location: /etc/passwd
Posts: 2,178
axilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to behold
 

Member of the Month
July 2005

http://php.net/number_format

thats the function your looking for i think
axilant is offline  
Old 07-29-2005, 09:57 AM THREAD STARTER               #5 (permalink)
Senior Member
 
Porte's Avatar
Join Date: May 2005
Location: I'm right here
Posts: 3,525
Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of
 



Well, this function does it..but I don't want to change the values since I'm dealing with money, like they convert 1234.56; to 1,235. I would rather want it to be 1,234.56 just the same but with formatting of thousands.

Edit: I figured something It worked for me, but I'm not sure if its 100% accurate

Quote:
<?
????: NamePros.com http://www.namepros.com/programming/110883-money-values-in-mysql.html
$number = 1000;
$do_format = number_format($number, 2, '.', ',');
echo $do_format;
?>
Output: 1,000.00

It seems to be working fine so if your values are stored in mysql as float type numbers just extract the value and format it using that function, it should look fine with thousands, this is useful for online stores/IPN.
thanks for everyone assistance.

Now, that we created the number format; we can still convert it to a regular float to use it in database or something;

echo str_replace(',', '', $do_format);

like this, I tried it and it worked.

Thanks axilant for the key, that function was what I was looking for.
Good luck everyone
__________________
WP Theme Developer
Your One-stop for Premium Magazine/CMS WordPress Themes
Deluxe Themes
Porte is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial: How to Install Apache2 MySQL and PHP on Windows deadserious Webmaster Tutorials 35 09-21-2005 09:46 PM
HUGE Reseller Plans! Limited Quanity Left. Only $12.95 a month. 30 Day Money Back! inogenius For Sale / Advertising Board 0 11-28-2004 05:50 PM
Modern Day "Who's On First" (but in Computerese) suthra The Break Room 2 06-25-2004 07:02 AM

 
All times are GMT -7. The time now is 12:09 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger