PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 13th, 2008, 11:54 AM
kelley5454 kelley5454 is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Aug 2008
Posts: 16 kelley5454 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 50 m 22 sec
Reputation Power: 0
Strange Occurence with zip code locator

Hi everyone, I have a strange thing happening with a zip code locator. I have two sets of zip codes that I have verified are in my data tables correctly. There are stores in the data base with these zipcodes. When entered into the page the zip code show a different store, it is not finding the actual store inside that zip code. I can't for the life of me figure out why this is happening.

Something to note is if I change the store zipcodes to a different zip code not in the two ranges that aren't working, the locator works perfect and finds the stores right away.

Thanks for your help

PHP Code:
<?php

require_once( 'classes/ZipCodesRange.class.php' );

// Get Values
$zip $_POST['zip'];
$distance 25;
$limit 3;
$ret '';
$count 1;
$retArray = array();
            
if((
is_numeric($zip)) && (strlen($zip) == 5)) {
            
//initialization, pass in DB connection, from zip code, distance in miles.
$dbInfo mysql_connect('localhost''root''******');
mysql_select_db('chd');

$rzip = new ZipCodesRange($dbInfo,$zip,$distance);

//configuration
$rzip->setTableName('zipcodes'); //optional, default is zips.
$rzip->setZipColumn('ZipCode'); //optional, default is zip.
$rzip->setLonColumn('Longitude'); //optional, default is lon.
$rzip->setLatColumn('Latitude'); //optional, default is lat.

//do the work
$rzip->setZipCodesInRange(); //call to initialize zip array

//zip code output, other processing can be done from this array.
$zipArray $rzip->getZipCodesInRange();

$zipFinal "";
foreach (
$zipArray as $key => $value) {
    
$zipFinal .= "'" $key "',";
}
$zipFinal substr_replace($zipFinal,"",-1);

//clear all other "AND" queries bellow
$where "chd_dealers.ZipCode IN ($zipFinal)";
    
$dbQuery mysql_query("SELECT
chd_dealers.Name,
chd_dealers.Address,
chd_dealers.City,
chd_dealers.State,
chd_dealers.ZipCode,
chd_dealers.Phone,
chd_dealers.`Web Address`,
chd_dealers.`e-mail`
FROM
chd_dealers
WHERE
"
.$where."
LIMIT "
.$limit);

$countResult mysql_num_rows($dbQuery);

if (
$countResult == 0) {
$ret .= "<center><h4>Your zip code is outside of<br/> the program area.<br/><center> Please visit <br/> <center><a href=\"**********\" > The Honda Dealers of the Carolinas</a> <br/> to find a dealer near you.</h4>";
}
else {
    
$ret .= "<h3></h3>";
    
while (
$dbRow mysql_fetch_array($dbQuery)) {
    
// reset return variable
$retA '';

// get distance
foreach ($zipArray as $key => $value) {
    if (
$dbRow['ZipCode'] == $key) {
        
$dis $value;
    }
}    
    
$tempUrl $dbRow['Web Address'];
if (
$tempUrl[0] == 'w') {
    
$dbRow['Web Address'] = "http://".$dbRow['Web Address'];
}



Kelley

Last edited by kelley5454 : October 13th, 2008 at 12:01 PM. Reason: Update

Reply With Quote
  #2  
Old October 13th, 2008, 04:20 PM
rbrown rbrown is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 80 rbrown User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 5 h 45 m 47 sec
Reputation Power: 3
Just guessing here... it sounds like your lats and lons are wrong or the calculation for them has a problem like getting the wrong data or changing the format. Have you looked at that section of code and outputted it step by step?

Bob

Quote:
Originally Posted by kelley5454
Hi everyone, I have a strange thing happening with a zip code locator. I have two sets of zip codes that I have verified are in my data tables correctly. There are stores in the data base with these zipcodes. When entered into the page the zip code show a different store, it is not finding the actual store inside that zip code. I can't for the life of me figure out why this is happening.

Something to note is if I change the store zipcodes to a different zip code not in the two ranges that aren't working, the locator works perfect and finds the stores right away.

Thanks for your help

PHP Code:
<?php

require_once( 'classes/ZipCodesRange.class.php' );

// Get Values
$zip $_POST['zip'];
$distance 25;
$limit 3;
$ret '';
$count 1;
$retArray = array();
            
if((
is_numeric($zip)) && (strlen($zip) == 5)) {
            
//initialization, pass in DB connection, from zip code, distance in miles.
$dbInfo mysql_connect('localhost''root''******');
mysql_select_db('chd');

$rzip = new ZipCodesRange($dbInfo,$zip,$distance);

//configuration
$rzip->setTableName('zipcodes'); //optional, default is zips.
$rzip->setZipColumn('ZipCode'); //optional, default is zip.
$rzip->setLonColumn('Longitude'); //optional, default is lon.
$rzip->setLatColumn('Latitude'); //optional, default is lat.

//do the work
$rzip->setZipCodesInRange(); //call to initialize zip array

//zip code output, other processing can be done from this array.
$zipArray $rzip->getZipCodesInRange();

$zipFinal "";
foreach (
$zipArray as $key => $value) {
    
$zipFinal .= "'" $key "',";
}
$zipFinal substr_replace($zipFinal,"",-1);

//clear all other "AND" queries bellow
$where "chd_dealers.ZipCode IN ($zipFinal)";
    
$dbQuery mysql_query("SELECT
chd_dealers.Name,
chd_dealers.Address,
chd_dealers.City,
chd_dealers.State,
chd_dealers.ZipCode,
chd_dealers.Phone,
chd_dealers.`Web Address`,
chd_dealers.`e-mail`
FROM
chd_dealers
WHERE
"
.$where."
LIMIT "
.$limit);

$countResult mysql_num_rows($dbQuery);

if (
$countResult == 0) {
$ret .= "<center><h4>Your zip code is outside of<br/> the program area.<br/><center> Please visit <br/> <center><a href=\"**********\" > The Honda Dealers of the Carolinas</a> <br/> to find a dealer near you.</h4>";
}
else {
    
$ret .= "<h3></h3>";
    
while (
$dbRow mysql_fetch_array($dbQuery)) {
    
// reset return variable
$retA '';

// get distance
foreach ($zipArray as $key => $value) {
    if (
$dbRow['ZipCode'] == $key) {
        
$dis $value;
    }
}    
    
$tempUrl $dbRow['Web Address'];
if (
$tempUrl[0] == 'w') {
    
$dbRow['Web Address'] = "http://".$dbRow['Web Address'];
}



Kelley
__________________
Bob

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Strange Occurence with zip code locator


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT