Current location: Hot Scripts Forums » Programming Languages » PHP » Zip Code search range errors


Zip Code search range errors

Reply
  #1 (permalink)  
Old 02-09-06, 01:31 AM
Merovingian's Avatar
Merovingian Merovingian is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Los Angeles
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Zip Code search range errors

I am having some issues getting this new code implemented using a SQL Server as the DB and using odbc_connect to interface with the database.

The current script itself selects a postal code and outputs its contents if its available and a message when the person's postal code is not available in the database.

Now my dilemma is this:
There is another table with the following rows: Latitude, Longitude, Region, that was previously installed. What I would like to be able to do is that when a user enters their postal code, instead of showing an error message for when their zip isnt available in the database, to actually show another zip code that is within range ( a postal code search that outputs results with in range.) .
Please bare in mind that I do not wish to purchase any scripts but instead would like to learn how to do this. Any help would be appreciated.

What is being used at the moment for the normal search:

PHP Code:

 $query "SELECT * FROM SonataLabs_DealerLocater WHERE (PostalCode LIKE '%$search%') ORDER BY DealerID";

$result odbc_exec($connection$query);

if(!
$result)
{
    echo 
"<strong>No query was made !</strong>";
    }
    else
    {
print <<<EOF
<table width="80%" cellpadding="10" cellspacing="2" border="0" align="center">
<tr>
    <td bgcolor="#f2f2f2" width="250"><strong>Dealer Name</strong></td>
    <td bgcolor="#f2f2f2" width="150"><strong>Address</strong></td>
    <td bgcolor="#f2f2f2"><strong>Telephone</strong></td>
    <td bgcolor="#f2f2f2"><strong>Email</strong></td>
    <td bgcolor="#f2f2f2"><strong>URL</strong></td>
    </tr>
</td>
<tr>
    <td  width="250">
EOF;

while(
$row odbc_fetch_array($result)  && $numRows odbc_num_rows($connection$query))
{

if(
$numRows )
{
    echo 
"There were no Dealers in your zip code area";    
   }else{

//Return the db queries
  
echo strtolower($row['Name']);
  echo 
"</td><td  width='150'>";
  echo @
$row['Street']; 
  echo 
"</td><td>";
  echo @
$row['Phone'];
  echo 
"</td><td>";
  echo 
"<a href=\"mailto:".@$row['Email']." \">".$row['Email']."</a>";
  echo 
"</td><td>";
  echo @
$row['URL'];
echo 
"</td>";
 
// echo '</td><td>'.odbc_result($result,"Address").'</td>';
  
echo "</tr>";
}
print <<<EOF
</table>
EOF; 
__________________
"Duo seguere aut de via decede" ...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 02-09-06, 02:19 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
could you give more details about the "range" you are seeking?
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 02-09-06, 04:33 PM
Merovingian's Avatar
Merovingian Merovingian is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Los Angeles
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
something like this;

For example:

A user enters 33165, it will search for that zipcode and any other postal codes with in range(miles?) of the actual 33165 postal code. If nothing is within that postal code just output a "Nothing found near you".
__________________
"Duo seguere aut de via decede" ...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Directory Search by Zip Code Recommendation rick6823 PHP 0 11-03-05 04:03 AM
Business Directory like yahoo.. zip code help APuppyDog PHP 2 09-17-05 09:20 AM
Disable form fields to be submitted RickyRod JavaScript 2 05-24-04 11:15 AM
Declared Functions skipper23 PHP 4 12-17-03 11:06 AM
index page not showing up skipper23 PHP 3 12-15-03 02:10 PM


All times are GMT -5. The time now is 06:50 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.