Jump to content

[SOLVED] How to get a PROPER sort with PHP


PHPNewbie55

Recommended Posts

I don't know if there is a work around for this but I am having a problem sorting records correctly based on PRICE.

 

It seems that PHP/MySQL does not sort the records correctly when they are being sorted by a NUMBER...

 

Example:

 

I sort my data by PRICE -- ASCENDING...

I get::

10.17

10.98

10.99

108.49

110.98

99.98

98.49

97.50

 

It seems that it just goes by the first number and that's it...

All 1's get put together no matter if it's 100 or 1000..

 

It happens in PHPmyADMIN too... so it seems to be a BUG in PHP...

 

Any way to get PHP to actually sort the data correctly..??

 

Link to comment
Share on other sites

Cool... I'll try that.. either way I have some code to rewrite...

 

The default LENGTH/VALUES for DECIMAL is 10,0 so it auto rounds the number up...

If you set the LENGTH/VALUES to 10,2 it gives the decimal points without rounding.

 

 

Thanks... just asking this one question I have learned a couple of things I didn't know before.....!!!

 

VERY MUCH APPRECIATED....

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.