This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

How to Alphabetically sort concat information


  1. hareem
    Member

    Hello. MachForm is a great product.It saved me a lot of headaches. I would like to know how can i sort my contacts forms info alphabetically.

    Please help

    Humble Regards
    Hareem Haque

    Posted 14 years ago #
  2. yuniar

    Sorry, I'm afraid there is no easy way to sort the entries yet.
    At this moment, you can do this by exporting the entries into excel file and sort it there.


    MachForm Founder

    Posted 14 years ago #
  3. meltingsand
    Member

    I just figured out a way to sort the data, and it is pretty easy. Now I can just click on a column heading to sort that field, and click again to sort in the reverse order. I'll paste my code real quick. I've done some other modifications so I can't give you line numbers since they'll be wrong. I'll paste what I have, and you should be able to find it pretty easily.

    In file manage_entries.php:

    Look for this code (I have bolded what I changed):

    //print table header
    foreach ($column_label as $table_header){
    if($table_header['name'] == 'id'){
    echo '<th scope="col" class="me_action">'.$table_header['label'].'</th>';
    }elseif ($table_header['name'] == 'row_num'){
    echo '<th scope="col" class="me_number">'.$table_header['label'].'</th>';
    }else{
    <em>if ($order == "desc") { $reverse = "asc"; } else { $reverse = "desc";}
    if ($sort == $table_header['name']) { $sortid = "sortfield"; } else { $sortid = "sort"; }
    echo '<th scope="col" id="'.$sortid.'"><div>'.$table_header['label'].'</div></th>'; </em>
    }

    then change where the query is formed:

    <em> if (!isset($sort)) $sort="id";
    if (!isset($order)) $order="desc";
    </em>
    $field_list = implode(',',$column_prefs);
    <em>
    $query = "select id,id as row_num,{$field_list} from ap_form_{$form_id} order by $sort $order $limit";
    </em>

    Posted 14 years ago #
  4. meltingsand
    Member

    I tried to bold my section and it didn't work. Everything between the "" tags is what I changed.

    Posted 14 years ago #
  5. isak
    Member

    Can you make this a little clearer? I could definitely use it.

    I think my problem is in the query section. Maybe I am not setting it up right. Perhaps you could include more of the code for this section so I can see how to add it and where?

    About the tags -- omit them? Include them?

    Thanks.

    Posted 14 years ago #
  6. redluss
    Member

    Thanks for this post - very exciting.

    I did find one issue in the code - you need to remove the from the top section of code as it's not supposed to be there - it was falsely translated by the help forum.
    However, as a novice at PHP, could you post a little more detail as to where the code under "Then change where the query is formed" is supposed to go? I'm having a hard time figuring out where the query should be inserted into the code.

    Thanks.

    Posted 14 years ago #
  7. Machmail
    Member

    I'd like to buy this script, but this solution works?

    Posted 12 years ago #

RSS feed for this topic

Reply