Hi everyone. I have list of postcodes. And what i'm trying to do is get a listing of similar poscodes only. My Code: $postcode1 = ereg_replace('[^A-Za-z]', '', $postcode); SELECT * FROM coverparked WHERE postcode LIKE '$postcode1%' ORDER BY postcode Code (markup): So then $postcode1 strips all number from postcode, so for example E16 is strpped down to E only, then using the mysql query i get all the postcodes from database starting with E, problem is that i also get listing of postodes starting with EC, EN ... and i want postcodes sarting with E only. Tried some options but i can't get to make it work.. Can you help me out here please .. Thanks a lot in advance in advance.
You can try with mysql REGEXP (http://dev.mysql.com/doc/refman/5.1/en/regexp.html) something like: /^e*[0-9]
If it's only the first letter you are looking for why not use PHP to take the first letter? $first_letter = substr($postcode, 0, 1); PHP: http://php.net/manual/en/function.substr.php