here is my code not getting right result.
--------------------------------------------------------------------
<CFPARAM name="errormessage" type="string" default="">
<CFPARAM name="passedzipcode" type="string"
default="78626">
<cfquery name="passedzip" datasource="TEST">
SELECT * FROM zip_codes
WHERE ZIPcode=#passedzipcode#
</cfquery>
<cfif passedzip.recordcount eq 0>
<cfset errormessage = "No records found for passed search
#passedzipcode#">
<cfabort>
</cfif>
<cfif errormessage eq ''>
<cfquery datasource="TEST" name="getlocs">
SELECT zipcode, latitude, longitude, state, city,
ROUND((ACOS((SIN(#passedzip.latitude#/57.2958) *
SIN(latitude/57.2958)) +
(COS(#passedzip.latitude#/57.2958) * COS(latitude/57.2958) *
COS(longitude/57.2958 - #passedzip.longitude#/57.2958))))
* 3963,15) AS distance
FROM zip_codes
WHERE (latitude >= #passedzip.latitude# -
(#passedradius#/111))
And (latitude <= #passedzip.latitude# +
(#passedradius#/111))
AND (longitude >= #passedzip.longitude# -
(#passedradius#/111))
AND (longitude <= #passedzip.longitude# +
(#passedradius#/111))
ORDER BY distance
</cfquery>
</cfif>
<CFPARAM name="dsname" type="string" default="your
datasource name">
<CFPARAM name="passedzipcode" type="string"
default="78626">
<CFPARAM name="passedradius" type="string"
default="20">
<CFPARAM name="passedreturndataformat" type="string"
default="table">
<CFPARAM name="passedreturneddata" type="string"
default="">
<CFPARAM name="rowonecolor" type="string"
default="whitesmoke">
<CFPARAM name="rowtwocolor" type="string"
default="white">
<CFPARAM name="rowthreecolor" type="string"
default="000080">
<cfif passedreturndataformat eq 'table'>
<cfset passedreturneddata = passedreturneddata &
"<table width=55% border=0 cellpadding=0 cellspacing=0>
<!--- this is used to make the headers of the table
colored --->
<tr>
<td valign=""center"" align=""center""
bgcolor=""#rowthreecolor#""><font
color=""#rowtwocolor#"">City</font></td>
<td valign=""center"" align=""center""
bgcolor=""#rowthreecolor#""><font
color=""#rowtwocolor#"">State</font></td>
<td valign=""center"" align=""center""
bgcolor=""#rowthreecolor#""><font
color=""#rowtwocolor#"">ZipCode</font></td>
<td valign=""center"" align=""center""
bgcolor=""#rowthreecolor#""><font
color=""#rowtwocolor#"">Distance</font></td>
</tr>">
<cfoutput query="getlocs">
<!--- this is used to make the headers of the table
colored --->
<!--- cf_bgcolortoggle can be downloaded from
cfmsource.com --->
<cfset passedreturneddata = passedreturneddata & "
<tr>
<td align=""center"" >#city#</td>
<td align=""center"" >#state#</td>
<td align=""center"" >#zipcode#</td>
<td align=""center"">#round(distance)#</td>
</tr>">
</cfoutput>
<cfset passedreturneddata = passedreturneddata & "
</table>">
<cfset errormessage = "">
<cfelse>
<cfset passedreturneddata = "">
<cfoutput query="getlocs">
<cfif passedreturneddata gt "">
<cfset passedreturneddata = passedreturneddata &
"|#city#,#state#,#zipcode#,#round(distance)#">
<cfelse>
<cfset passedreturneddata = passedreturneddata &
"#city#,#state#,#zipcode#,#round(distance)#">
</cfif>
</cfoutput>
<cfset errormessage = "">
</cfif>
<cfoutput>
<cfif errormessage gt ''>
#errormessage#
<cfelse>
#passedreturneddata#
</cfif>
</cfoutput>