Guest nedra Posted December 29, 2010 Report Share Posted December 29, 2010 Hi everyone, I've just spent about 4 hours trying to solve this, but I'm having an awful amount of trouble and I decided to come to the experts. If we look at my rank directory here: http://www.unityvirtual.net/index.php/rank, we can see that it is sorting the ranks from Lowest (Pilot Recruit) up the top, to Highest (CEO) down the bottom. This makes sense, because the 'rankid' for Pilot Recruit is '1', while the rankid for CEO is '12'...No problems there. However, I'm trying to swap the order that the ranks appear on that page, without changing any rankid's in the database. I've tried a few things, but nothing has seemed to work, and Google hasn't helped, unfortunately. The code for my ranks_allranks.tpl is: <center><h3>Unity Virtual Ranks</h3> <table id="tabledlist" class="tablesorter"> <thead> <tr> <th>Rank Image</th> <th>Rank</th> <th>Salary</th> <th>Description</th> </center> </tr> </thead> <tbody> <?php foreach($ranks as $rank) { ?> <tr id="row<?php echo $rank->rankid;?>"> <td align="center" width="200px"><img src="<?php echo $rank->profrankimage; ?>" /></td> <td align="center" width="150px"><?php echo $rank->rank; ?></td> <td align="center" width="50px">$<?php echo $rank->payrate; ?> per hour</td> <td align="justify"><?php echo $rank->rankrequire; ?></td> </tr> <?php } ?> </tbody> </table> If anyone can please help, i will be eternally grateful. I'm fairly sure it's an easy fix, but anything I've tried hasn't worked. Thanks very much in advance! Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted December 30, 2010 Administrators Report Share Posted December 30, 2010 You need to change the sql command that is loading the $ranks variable. It is probably ending in something like ORDER BY minhours ASC Change the ASC to DESC and it should reverse the order. Quote Link to comment Share on other sites More sharing options...
Guest nedra Posted December 31, 2010 Report Share Posted December 31, 2010 Hi Simpilot, thanks for getting back to me! Quick question: Where can I find the SQL Command $Ranks variable? Thanks very much, and Happy New Year Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted December 31, 2010 Administrators Report Share Posted December 31, 2010 Looks like you have a custom module named "rank", the code that you are pulling the data from should be in there, or at least the call for it. If it using the native phpVMS function; RanksData::getAllRanks() you would find the line to change in the RanksData.class.php file on line 46; ORDER BY r.minhours ASC'; but this function should already be ordering from biggest to smallest using the ASC command, so my guess is that it is a custom function within the rank module or a custom data class and you should find something similar to what I have shown here except using the DESC command or no ORDER BY command at all. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.