BigTime Posted March 21, 2009 Share Posted March 21, 2009 I need to order returned data by a certain column but not in a DEC or ASC order Is it possible to do this via an array? //the order you want to sort in an array $sortArray = array(Heavyweight,Lightweight,Middleweight,Featherweight,Bantamweight); //turn that array into a string for use in the query. $sortString = implode(',', $sortArray); How do I implement this array into the ORBER BY clause??? Is it possible? If one of the entries in my array does not exist in the database will I get an error? Quote Link to comment https://forums.phpfreaks.com/topic/150443-order-query-by-array/ Share on other sites More sharing options...
sasa Posted March 21, 2009 Share Posted March 21, 2009 ... ORDER BY FIND_IN_SET(field_name, 'Heavyweight,Lightweight,Middleweight,Featherweight,Bantamweight') http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in-set Quote Link to comment https://forums.phpfreaks.com/topic/150443-order-query-by-array/#findComment-790176 Share on other sites More sharing options...
Maq Posted March 21, 2009 Share Posted March 21, 2009 Please don't double post BigTime... Quote Link to comment https://forums.phpfreaks.com/topic/150443-order-query-by-array/#findComment-790179 Share on other sites More sharing options...
BigTime Posted March 21, 2009 Author Share Posted March 21, 2009 Please don't double post BigTime... Uhhhh....huh? Im not double posting!?! WTF! Just feel like throwing something spicy out there randomly? Sasa! thank you VERY much! AND for the link to the SQL functions Quote Link to comment https://forums.phpfreaks.com/topic/150443-order-query-by-array/#findComment-790295 Share on other sites More sharing options...
Maq Posted March 21, 2009 Share Posted March 21, 2009 Uhhhh....huh? Im not double posting!?! WTF! Just feel like throwing something spicy out there randomly? Looking back at the posts I see that you didn't double post, my mistake :'( Quote Link to comment https://forums.phpfreaks.com/topic/150443-order-query-by-array/#findComment-790581 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.