Hey,

I have a database which contains many definitions. The definitions are all numbered like this:

1.1 bla bla
1.2 blal balk bla
1.3 labklaklb

I want to display the definitions in order of the numbers, but if i have a number like 1.10 or 1.11, it will place itself below 1.1, like this:

1.1 bla bla
1.10 akjfj
1.2 aksdhfk...

It's important that it doesn't do that because I have an option to add definition which will change the numbers therefore it will change the order. Does anybody know how I could fix this? One options i thought is to renumber them like this:

1.001, 1.002, 1.010, but I'd rather keep them like they are now.

    Rather than renumbering 1.001, 1.009, 1.010, you might consider dividing the number field into two separate fields, 1 chapter, and 1 section, and then using the SQL or PHP that calls the queries to assemble them into ('chapter') . "." . ('section') ORDER BY chapter, section
    It would seem more flexible in the long run, and be less prone to uncontrollable errors.

      I don't have an example handy but you can use the SELECT string functions to break the number into two calculated fields and then sort.

      http://www.mysql.com/doc/en/String_functions.html

      It woul be faster though to simply add a sort column to the table and set it's value for each insert/update.

        Write a Reply...