Jump to content

Help with advanced search code (in Drupal)


samoht

Recommended Posts

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?

 

 

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)))
{
//.....
}

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.