karvenki12 Posted February 24, 2011 Share Posted February 24, 2011 Hi, I am trying to figure out how to sort my data either in ASC or DESC order. I tried using set::sort method, paginator:sort method, but not able to find a solution for this. The code that I am currently working on is pasted below. I need to sort the members data by their lastname. I would really appreciate if someone can help me with this. Thank you, <div class="members view"> <h2><?php __('Members associated with <b>'.$programs['Program']['name'].'</b>')?></h2> <table cellpadding="0" cellspacing="0"> <tr> <th>No</th> <th>Member</th> </tr> <?php $i = 0; foreach ($members as $member): $class = null; if ($i++ % 2 == 0) { $class = ' class="altrow"'; } ?> tr<?php echo $class?>> <td><?=$i?></td> <td><?=$member['Member']['lastname']?>, <?=$member['Member']['firstname']?> <small><i>(<?=$member['Member']['publication_name']?>)</i></small></td> </tr>< <?php endforeach; ?> </table> </div> Link to comment https://forums.phpfreaks.com/topic/228679-sorting-of-data/ Share on other sites More sharing options...
trq Posted February 24, 2011 Share Posted February 24, 2011 You might want to mention the framework your using, your post is pretty vague. Link to comment https://forums.phpfreaks.com/topic/228679-sorting-of-data/#findComment-1179032 Share on other sites More sharing options...
karvenki12 Posted February 24, 2011 Author Share Posted February 24, 2011 I am sorry about that. I am using cakePhP with Mysql. Relatively new to this framework. I needed help with the sorting of the members data by lastname as mentioned in the code above. Please let me know if you need more information. Link to comment https://forums.phpfreaks.com/topic/228679-sorting-of-data/#findComment-1179201 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.