Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Old 23rd January 2010, 00:50
edge edge is offline
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,045
Thanks: 270
Thanked 154 Times in 133 Posts
Default MySQL and currency (euro format)

I'm trying to code a small site with a search function on it.
One of the values that is can be search is the price of a product.

Till now I was stroring the price as a varchar() type, but this way it can not be used to do a search query with "BETWEEN". (example: BETWEEN 20 and 50)

Anyone here who can tell me what I should use as type in the MySQL?
Please note that the Dutch format of currency use is like this:
1.000,50 (one thousand euro and 50 cents) and:
25,75 (twenty five euro and seventy five cents)

Or.. Is there an other way of doing this?

Once again thank you for any info on this.
Reply With Quote
Sponsored Links
Old 23rd January 2010, 13:30
falko falko is offline
Super Moderator
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,752 Times in 2,582 Posts

I'd probably use DECIMAL. See http://dev.mysql.com/doc/refman/5.0/...ric-types.html

You can use the number_format() PHP function to convert the values into the right format.
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
The Following User Says Thank You to falko For This Useful Post:
edge (23rd January 2010)


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing a currency symbol in mysql database SpydrSS Programming/Scripts 3 12th July 2007 15:07

All times are GMT +2. The time now is 08:42.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.