phpQuestioner Posted March 25, 2007 Share Posted March 25, 2007 I have a datatable with a varchar field know as "price". At this time I have 3 rows in it; they are as follows: $ 18,500 $19,500 and $ 9,500. The problem is that when I try to sort in either ascending or descending order; it does not sort right. I know the problem lies in the $ 9,500, because I added a zero in front of the 9,500 (like this: $ 09,500) and it sorted fine. At first I thought it may have had something to do with the dollar sign, but it didn't because I removed and tested it without dollar sign and still had the same problem. What I want to know is, how I can make datatable sort accurately with putting a zero in front of the 9,500. I tried to use a CSS style to cover up the zero, but when I did that, datatable still would not sort the right way. MySQL code in my web page is accurate, because you can take the $ 9,500 and add a 5 digit number and it works fine. Anyone know what I need to do to fix this? Quote Link to comment https://forums.phpfreaks.com/topic/44199-solved-problem-sorting-currency/ Share on other sites More sharing options...
artacus Posted March 25, 2007 Share Posted March 25, 2007 Don't save it as a varchar, save it as an INT or DECIMAL. Add the $ and comma in php. Quote Link to comment https://forums.phpfreaks.com/topic/44199-solved-problem-sorting-currency/#findComment-214639 Share on other sites More sharing options...
MadTechie Posted March 25, 2007 Share Posted March 25, 2007 Ermm you asked this question already and its been solved !!! Quote Link to comment https://forums.phpfreaks.com/topic/44199-solved-problem-sorting-currency/#findComment-214673 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.