I'm searching mySQL by postcode. In the database I've got
'locations' with a postcode field containing the first letters of the post
code e.g.
WR3 7LX is WR,
M10 9UH is M
In my search form I get the user to enter their full post code and then I'm
trying to read it and pass the relevant string to a mySQL query. The code
I'm using should check the second character in the submitted post code,
check if it's a number. If it is then pass only the first letter. If it
isn't then pass the first two. The problem is that at the moment it only
passes the first letter no-matter what. Can anyone see where I'm going
wrong?
Code below
Pete Jones
// Perform String splitting to determine format of post code
$checked = substr($userpcode,1, 1);
if(($checked == 0)
||($checked == 1)
||($checked == 2)
||($checked == 3)
||($checked == 4)
||($checked == 5)
||($checked == 6)
||($checked == 7)
||($checked == 8)
||($checked == 9)):
$lpc = substr($userpcode,0,1);
print($lpc);
else:
$lpc = substr($userpcode,0,2);
print($lpc);
endif;