Join tables - one-to-many join Example - Ordering Access Options Alphabetically

Join tables - one-to-many join Example - Ordering Access Options Alphabetically

JonathanTolhurstJonathanTolhurst Posts: 11Questions: 7Answers: 0

Hi, In the example:
http://editor.datatables.net/examples/advanced/joinArray.html
How would you go about ordering the Access Options in the form alphabetically?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 55,097Questions: 1Answers: 8,651 Site admin
    Answer ✓

    Good point - I should do that in the example!

    In the PHP code there is:

        $out['access'] = $db
            ->select( 'access', 'id as value, name as label' )
            ->fetchAll();
    

    The select() method has four possible parameters:

    1. Table
    2. Fields
    3. Where condition
    4. Ordering

    So you would use:

        $out['access'] = $db
            ->select( 'access', 'id as value, name as label', null, 'name asc' )
            ->fetchAll();
    

    The PHP API documentation is available for the details of these methods, such as the above parameter options.

    Regards,
    Allan

This discussion has been closed.