Are you building a form where you have a drop down list of countries for users to choose from? If you are, you might find the following snippet handy.
Continue reading Country drop down menu
If you would like to force all your incoming URLs to have www at the front for SEO reasons, create an .htaccess file with the following content in the root directory of your website. RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] What is 301 redirect? 301 redirect is the most efficient and [...]
Continue reading www vs. non-www 301 redirect
One of the most important tasks of any developer is to know what errors occur in his application, because it is impossible to fix them if you don’t know if they exist in the first place. Although you may think that your application is perfect and bugs free, you can never be 100% sure because [...]
Continue reading Error logging in PHP
I am using WordPress as a CMS for one of my websites. For that website, instead of having a default category page, I wanted to have a customised category page which lists titles of all posts under that category. And I also wanted to display a category image if it exists in /wp-content/uploads/images folder. And [...]
Continue reading Customising category.php in WordPress
The following CSS selectors are considered workarounds and hacks for specific web browsers. IE 6 and below * html {} IE 7 and below *:first-child+html {} * html {} IE 7 only *:first-child+html {} IE 7 and modern browsers only html>body {} Modern browsers only (not IE 7) html>/**/body {} Recent Opera versions 9 and [...]
Continue reading CSS Hacks (for IE 7, IE 6, Opera, etc)
Use LEFT JOIN when you want to return all rows from left table regardless of whether they have any associated rows on right table. Use RIGHT JOIN when you want to return all rows from right table regardless of whether they have any associated rows on left table. SELECT users.`firstname`, pets.`nickname` FROM `users` LEFT JOIN [...]
Continue reading LEFT JOIN and RIGHT JOIN in mysql
This blog’s title (have a look in the title bar ^) has been seo-ed to the max. Here’s what I put in header.php of my current theme. <title> <?php wp_title($sep = ”);?> <?php if (is_home()) { bloginfo(‘description’); } ?> – <?php bloginfo(‘name’); ?> </title> Robert thinks it’s cool! What about you? [Edit] Here’s yet better [...]
Continue reading Search engine friendly WordPress titles
UPDATE `tablename` SET `columnname` = TRIM(LEADING ‘THE CHARACTER YOU WANT TO REMOVE, eg: A’ FROM `columnname`); TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str), TRIM([remstr FROM] str) Returns the string str with all remstr prefixes or suffixes removed. If none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed. remstr is optional [...]
Continue reading Remove the first character in mysql
function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName(“a”); for (var i=0; i<anchors.length; i++) { var anchor = anchors[i]; if (anchor.getAttribute(“href”) && anchor.getAttribute(“rel”) == “external”) anchor.target = “_blank”; } } window.onload = externalLinks; Source: Sitepoint
Continue reading New-Window Links in a Standards-Compliant World
UPDATE `table` SET `field` = CONCAT(`field`, ‘ append text’);
Continue reading Apending text to a field which isn’t empty (mysql)
Hello! Welcome to Web development blog! My name is Ei Sabai and on this blog, I write about web development, mobile app development, latest web technologies and the likes. Read more 

