blakekr Posted May 7, 2008 Share Posted May 7, 2008 Someone very good at mysql helped me create an ORDER BY statement that would allow my program to display item names alphabetically without putting items in quotes at the beginning. Works a charm, except I can't figure out how to craft a REPLACE statement that ignores more than one type of punctuation ... e.g. I need to ignore both double quotes and single quotes at least. Here is my original statement -- works great: if ($SortBy == 1) { // Either explicit or default set above $orderBy = "category , REPLACE(`prod_name`,'\"', '') "; Here is my attempt to ignore both double and single quotes, doesn't work as expected: if ($SortBy == 1) { // Either explicit or default set above $orderBy = "category , REPLACE(REPLACE('prod_name','\\\"',''),'\'','') "; Any advice appreciated! Thanks, Blake Quote Link to comment https://forums.phpfreaks.com/topic/104570-solved-using-replace-to-sort-alphabetically-ignoring-punctuation/ Share on other sites More sharing options...
mezise Posted May 7, 2008 Share Posted May 7, 2008 Hi, in inner REPLACE you are searching for \" instead of ". This code should work: if ($SortBy == 1) { // Either explicit or default set above $orderBy = "category , REPLACE(REPLACE('prod_name','"',''),'\'','') "; Quote Link to comment https://forums.phpfreaks.com/topic/104570-solved-using-replace-to-sort-alphabetically-ignoring-punctuation/#findComment-535379 Share on other sites More sharing options...
blakekr Posted May 8, 2008 Author Share Posted May 8, 2008 Thanks so much, this was tremendously helpful! Quote Link to comment https://forums.phpfreaks.com/topic/104570-solved-using-replace-to-sort-alphabetically-ignoring-punctuation/#findComment-535691 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.