phpdragon Posted February 23, 2009 Share Posted February 23, 2009 I have a mysql query selecting items from a DB, it has a field in the table called status which can only have one of the following 4 values (pending, allocated, packed, completed), my question is how can I display them, in that order, i have them listed in now. every item will have one of these status levels. Quote Link to comment https://forums.phpfreaks.com/topic/146479-solved-how-to-set-display-order-of-while-loop/ Share on other sites More sharing options...
Philip Posted February 23, 2009 Share Posted February 23, 2009 order by Quote Link to comment https://forums.phpfreaks.com/topic/146479-solved-how-to-set-display-order-of-while-loop/#findComment-768975 Share on other sites More sharing options...
phpdragon Posted February 23, 2009 Author Share Posted February 23, 2009 yes I understand order by but I dont want it listed alphabetically or numerically, I would like the list order in this fashion:- Pending Allocated Packed Completed this order doesnt comply to any of the above rules Quote Link to comment https://forums.phpfreaks.com/topic/146479-solved-how-to-set-display-order-of-while-loop/#findComment-768977 Share on other sites More sharing options...
PFMaBiSmAd Posted February 23, 2009 Share Posted February 23, 2009 See the March 28 2005 6:16pm User comment at this link - http://dev.mysql.com/doc/refman/5.0/en/sorting-rows.html Quote Link to comment https://forums.phpfreaks.com/topic/146479-solved-how-to-set-display-order-of-while-loop/#findComment-768988 Share on other sites More sharing options...
phpdragon Posted February 23, 2009 Author Share Posted February 23, 2009 Thankyou PFMaBiSmAd excellent link and problem solved for anyone else wanting to know here is a quote containing the answer Here's an example of Eamon Daly's point using the PET table - $sql="SELECT * FROM pet ORDER BY FIELD(species, 'cat', 'dog', 'bird')"; Quote Link to comment https://forums.phpfreaks.com/topic/146479-solved-how-to-set-display-order-of-while-loop/#findComment-769005 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.