Hi all,
simple but i just cant get my brain to function.
I have a field of locations, when i search lets say for example "london", i have london stored as "london *" in the database with "*", how can i find london, so i want to only find characters with [a-z] or [A-Z] or [0-9], missing out any special characters in the where statement
select * from tbl_location where lname = '$location'
query
Moderator: General Moderators
Code: Select all
<?php
preg_match("([A-Za-z0-9\s]+)", $row['location'], $match);
$location = $match[0];
?>above code is not meant to be used in the query, use it after you fetch the results to show only city names.
try:
try:
Code: Select all
<?php
$query = "select city from table where cityname LIKE '%$searchfield%'";
?>