Hi I am creating a reverse phone number look up in my database. I have a box that the user enters a phone number (in my example the number is 01772708200 NO SPACES etc) What I want to do is query my sql database and return matching results. The problem is my database contains thousands of numbers in different formats (I should have formated this at the start but I did not) and potentially the numbers could be represented as 01772 708200 or 01772 708 200 etc)
I have included a bit of script which I thought would trim the condition for the search but it does not work ;
$value="01772708200" ;
$condition = "TRIM(phone1) LIKE '%$value%' ";
$result = mysql_query("SELECT * FROM major WHERE $condition ") ;
value is the number entered by the user and just shown here as a variable for clarity .
phone1 is the phone number in my db table called major .
Can anyone suggest what I am doing wrong please ?
thanks