Results 1 to 3 of 3

Thread: Sorting numbers

  1. #1
    New user
    Join Date
    07-04-09.
    Posts
    17

    Default Sorting numbers

    Hi there,

    i got a slight problem with sorting starting numbers from a racing grid.

    http://supermoto-trophy.de/starterliste ... lheim.html

    The sorting "Startnummer" is wrong. It seems like this field is handled like a textfield isn´t it? Fieldtype in database is varchar. So sorting depends on digits..

    Is here a workaround to get this field handled numeric via template or backend? Otherwise i can change fieldtype in database.

    greetz
    Frank

  2. #2
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Sorting numbers

    Not really. Forms only store text, they don't allow any type of number field (at DB level).

    You'll have to copy the FormAutoListing, and hack away at it, or maybe use anothermodule to list the data (or write your own)...

    You can also check if the tl_form_fields table contains the rgxp="digit" string, as that will flag that field as numeric, so you can do a CAST or convertion of the data into a numeric value.

    Code:
    SELECT textfield1, textfield2, CAST(numfield1 AS UNSIGNED) FROM form_events ORDER BY CAST(numfield1 AS UNSIGNED) DESC
    Remember there is no space between the CAST and the ( bracket, otherwise it will generate an error.

  3. #3
    New user
    Join Date
    07-04-09.
    Posts
    17

    Default Re: Sorting numbers

    thx

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •