Posted in Joomla, MySQL, PHP on March 5, 2009
13
Alternate title: "Help! My Quotes Appear as Question Marks or Other Strange Characters!"
The "Smart quotes" feature in Microsoft Office transforms straight quotes into curly quotes. It also transforms hyphens into em-dashes and three periods into ellipses. While one might think, "How lovely! My document looks almost as if I'm educated!" readers of said document may not. Microsoft, in its infinite wisdom, decided to assign special characters such as the ones I just mentioned to a range of codes above 128. Problem: these codes were already assigned to other characters, resulting in frustrating incompatibility with non-Microsoft systems.
Keep reading for some PHP and MySQL code to help out with this issue, as well as a Joomla! plugin.
Read more...
Posted in MySQL on March 6, 2008
0
While writing a Power Search module for my accounting/customer management software, I came up with a great way to order results in MySQL.
The problem was this: some of our accounts are listed under a business name, and some are listed under a person's name. You couldn't order by `BusinessName`,`LastName` because all the accounts that didn't have a business name listed would appear first in the list. If you reversed it, all the accounts who had only a business name would appear first in the list. The solution, fortunately, was beyond simple:
order by CONCAT(`BusinessName`,`LastName`,`FirstName`)
This is equivalent to saying "Sort by BusinessName, if it doesn't exist then sort by LastName, if it doesn't exist then sort by FirstName. Yay!