ZIPzr Locator™ Code Examples

PHP

Screen shot of a PHP page returning search results:

Example code for PHP page:

<?php
//this is required for the web service call. it can be placed anywhere on the site as long as the path is updated. For PHP 5.x we use NuSOAP SOAP Toolkit which can be downloaded from here http://sourceforge.net/projects/nusoap/
require_once('nusoap2.php');

//this is the location of the web service call
$wsdl=new soapclientNusoap('http://www.zipzr.com/ws/Zipzr.cfc?WSDL');

//this calls the web service with the passed parameters from the form post. included in this is the clientid which selects the appropriate locations to search.
$output = $wsdl->call('zipZr',array('passedzipcode'=>$_POST['passedzipcode'],
'passedradius'=>$_POST['passedradius'],'clientid'=>$_POST['clientid']));

//this counts the array to verify if the proper data was passed back.
$count = count($output);

//if proper data is passed back, the array count will be equal to 1.
if ($count == 1) {

//this separates the locations by the delimiter in the return data. The returned data string is separated by a '^'
$locationList = explode("^",$output);


//initializes the record counter.
$i = 0;

//for every location (row) in the return data, loop through the location (columns) and print out the values.
foreach ($locationList as $valuea) {

print("<tr>");

//break apart the columns of each row. Columns are separated by a '|'.
$location = explode("|",$locationList[$i]);
print("<td>".$location[0]."</td>");
print("<td>".$location[2]);
if ($location[3] != "") {
print("<br>".$location[3]."</td>");
} else {
print("</td>");
}
print("<td>".$location[4]."</td>");
print("<td>".$location[5]."</td>");
print("<td>".$location[6]."</td>");
print("<td>".$location[7]."</td>");
print("<td>".$location[8]." Miles</td>");
//this prints out the products column. If you are not insterested in showing products or services available a location, you can remove it. if ($location[1] != "") {
print("<td>".$location[1]."</td>");
} else {
print("<td>No Info</td>");
}
//this cell can be removed. if removed, make sure you remove the table header named "Map" above.
print("<td><a href='http://maps.google.com/maps?f=q&hl=en&geocode=&
q=".urlencode(trim($location[2])));
if ($location[3] != "") {
print(",+".urlencode(trim($location[3])));
}
print(",+".urlencode(trim($location[4])).",+".urlencode(trim($location[5])).",+"
.urlencode(trim($location[6]))."&ie=UTF8&z=16&iwloc=addr' target='_blank'>Map It</a></td>");
print("</tr>");
//increment the counter.
$i++;
}

print("</table>");

} else {
//if the count did not equal 1, then print out the error message.
print("<tr><td colspan='8'>No Results for your search of ". $_POST['passedzipcode'] .". Try increasing the search radius.</td></tr></table>");

}

?>

ColdFusion

ColdFusion and other examples coming soon...