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.
Reply
 
Thread Tools Display Modes
  #1  
Old 22nd January 2010, 23:50
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,036
Thanks: 268
Thanked 152 Times in 132 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
  #2  
Old 23rd January 2010, 12:30
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,744 Times in 2,577 Posts
 
Default

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.
__________________
Falko
--
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)
Reply

Bookmarks

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 14:07


All times are GMT +2. The time now is 18:16.


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