drisate Posted October 5, 2009 Share Posted October 5, 2009 Hey guys ... how do you order a table by title asc when the first character are special characters like é or ê html encoded ? Once encoded they look like this : é and ê So when i try to sort them MySQL see's the & and places them at the begining ... How can i do this ? Link to comment https://forums.phpfreaks.com/topic/176609-sql-order/ Share on other sites More sharing options...
Code2004 Posted October 5, 2009 Share Posted October 5, 2009 I'm definitely not a professional programmer (yet ). But you have asked a fairly difficult question... In my opinion, I think it'd be fine to get all the results and translate them to real characters and then sort them in an array... Tons of ways of doing THAT. But it sounds like a good method to me! If anyone's got a better idea, please suggest :S. Link to comment https://forums.phpfreaks.com/topic/176609-sql-order/#findComment-931030 Share on other sites More sharing options...
drisate Posted October 5, 2009 Author Share Posted October 5, 2009 Yeah thats what i thought too ... but i was hopping for a magique function that would encode the col directly in the SQL line ... :-( something like SELECT * FROM lexique WHERE ( titre like 'Â%' or titre like 'À%' or titre like 'â%' or titre like 'à%' or LOWER(titre) like 'a%' ) order by html_entity_decode(titre) asc limit 0, 15 Link to comment https://forums.phpfreaks.com/topic/176609-sql-order/#findComment-931035 Share on other sites More sharing options...
cags Posted October 5, 2009 Share Posted October 5, 2009 I'm no expert either, but I don't think it will be possible. Personally I'd have thought the only way to successfully achieve the order would be to store the actual character in the database, not the html encode. Depending on the amount of records you could probably fetch the data then write a custom sort with PHP, or sort it after substituting the values, but if your doing that you may aswell store them in the db. Link to comment https://forums.phpfreaks.com/topic/176609-sql-order/#findComment-931047 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.