php - Ignore some letters in a postcode search. e.g Database contains DT11 but user searches DT11 0QD. -


i have code below postcode search. table in database holds area postcode values such [dt11] user search complete postcode [dt11 0qd].

how modify below code ignore information , display result?

<?php mysql_connect ("localhost","user","password") or die ("could not connect"); mysql_select_db("commun91_pres128") or die ("could not find database"); $output = ''; //collect if (isset($_post['search'])){ $searchq = $_post['search'];     $searchq = preg_replace("#[^0-9a-z]#i","",$searchq);      $query = mysql_query("select * ps_pcsearch firstname '%$searchq%' or lastname '%$searchq%'") or die ("could not search");     $count = mysql_num_rows ($query);     if ($count == 0){         $output = 'there no search results';     }else{         while ($row = mysql_fetch_array ($query)) {             $a = "your delivery day . . . ";             $lname = $row['lastname'];             $id = $row ['id'];              $output .= '<div>'.$a.' '.$lname.'</div>';               }         }     } ?> 

just use wildcards:

where $user_postcode concat('%', postcode, '%') 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -