samoht Posted December 23, 2008 Share Posted December 23, 2008 Hello, I am working on a Drupal site that has a advanced search for doctors based on "zip". The problem is that it will only return an exact match. I need to code it so that it will check for exact matches - then if none found - check for approximate match etc. does anyone know how to get started with this/ point me in the right direction? Link to comment https://forums.phpfreaks.com/topic/138094-help-with-advanced-search-code-in-drupal/ Share on other sites More sharing options...
MadTechie Posted December 23, 2008 Share Posted December 23, 2008 something like this $query = "SELECT * from Docs WHERE zip = '$zip'"; $result = mysql_query($query); if(mysql_num_rows($result) == 0) // no exact found// try like { $query = "SELECT * from Docs WHERE LIKE = '%$zip%'"; $result = mysql_query($query); if(mysql_num_rows($result) == 0) { die('No docs Ahhhhh!'); // none found } } while (($rows = mysql_fetch_assoc($result))) { //..... } Link to comment https://forums.phpfreaks.com/topic/138094-help-with-advanced-search-code-in-drupal/#findComment-721861 Share on other sites More sharing options...
trq Posted December 23, 2008 Share Posted December 23, 2008 A query like..... SELECT * from Docs WHERE LIKE = '%$zip%' Will match both exact and strings containing. Link to comment https://forums.phpfreaks.com/topic/138094-help-with-advanced-search-code-in-drupal/#findComment-721915 Share on other sites More sharing options...
samoht Posted December 23, 2008 Author Share Posted December 23, 2008 OK, but it is probably not just the zip numbers I will need to check. for example if a zip is near the border of a state the numbers of zip with-in a five mile radius maybe quite different even though they're right next to each other. ??? Link to comment https://forums.phpfreaks.com/topic/138094-help-with-advanced-search-code-in-drupal/#findComment-721923 Share on other sites More sharing options...
MadTechie Posted December 23, 2008 Share Posted December 23, 2008 A query like..... SELECT * from Docs WHERE LIKE = '%$zip%' Will match both exact and strings containing. true but I need to code it so that it will check for exact matches - then if none found - check for approximate match etc. @samoht your need a zipcode database google it and read the doc Link to comment https://forums.phpfreaks.com/topic/138094-help-with-advanced-search-code-in-drupal/#findComment-721931 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.