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?

 

 

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.