Click Here[1] UnderConstruction please go to upper link and click on SIGNUP TO DRIVE (Blue cruve Button) there will be a tab open type london (Not From Drop Down) only just type london and hit enter page will redirect to

page (This mean post keyword matched 100% with database) than come back to previous page and again type london now this time from Dropdown menu
you will find London, United Kingdom,and hit enter. They are same city but my database have only keyword page will redirect to

This mean result not matched 100%

I want to match only city London, United Kingdom to my database Keyword london.
I only have letters london in my database here is my code.

require_once "connection/connection.php";
   $a  = $_POST['address'] ;
   $sql = "SELECT * FROM tbl_city WHERE city_name LIKE '%$a%'"; 
   $res  = mysql_query($sql);   
   $result = mysql_fetch_array($res); 

   if($result >=1){

where $a = $_POST['address'] ; is input field name (Where it is use for search) so please let me know how can I match the city from my database?my database is given below

`id` int(100) NOT NULL,
 `city_name` varchar(100) NOT NULL

  INSERT INTO `tbl_city` (`id`, `city_name`) VALUES
  (1, 'london');

Now please help me to find out solution. Remember i have used REGEXP MATCH() ... AGAINST in $sql is most challenging ever.
Anyone have Solution???

Re: I want to match data from my database to googlelocation dropdown 80 80

If you're always going to have the same format of the city with a comma followed by something, you could just write the query with a substring_index to split on the comma. If it isn't always going to be that way, then of course you wouldn't be able to do that.

SELECT * FROM tbl_city WHERE city_name LIKE SUBSTRING_INDEX('London, United Kingdom', ',', 1);

This splits the string on the first comma, and uses the value of 'London' in the search.


You could split the string in PHP prior to running the query.

commented: great you have done it thanks +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.