Looping, Setting and Updating! Oh My.
hello all, new cf , our regular guy on vaction use help. getting geo location bing multiple address have in db. add latitude , longitude latitude field , longitude field in respective row able run function(s) indivulally need looping through each row. here have. hope makes sense!
<!---query db--->
<cfquery datasource="square" name="listingshort">
select
mls_id,list_price,public_address,street_number,street_name,unit_number,city,zip_code,subd ivision_name,bedroom,baths_total,full_baths,half_baths,square_feet,lot_sqft,garage_capacit y,garage_type,high_school,junior_school,property_description,listing_office_name,listing_o ffice_id,listing_agent_name,listing_agent_phone,listing_agent_id,short_sale,open_house_fla g,last_image_update,price_change_date,image_count,latitude,longitude
glvar_daily_bulk
where mls_id=1375233
</cfquery>
<!---get data bing--->
<cfhttp url="http://dev.virtualearth.net/rest/v1/locations/us/nv/#listingshort.zip_code#/#listingshort. city#/#listingshort.street_number#%20#listingshort.street_name#?o=xml&key=agm3wr0ojspxyaje h6ws7p2kcckecqvq5hkrwefczccyoje3myvvirf_wzbetmeb" timeout = "2" method="get">
<cfset xbinglocation = xmlparse(cfhttp.filecontent)>
<cfset lat=xbinglocation.response.resourcesets.resourceset.resources.location.point.latitude.xml text>
<cfset long=xbinglocation.response.resourcesets.resourceset.resources.location.point.longitude.x mltext>
<!---update latitude , longitude fields--->
<cfquery datasource="square" name="addgeo">
update glvar_daily_bulk
set latitude = #lat#,
longitude = #long#
mls_id=1375233
</cfquery>
do need loop on rows, or of them? i'm assuming former. in case modify first query records, move rest of code loop on query.
<!---query db--->
<cfquery datasource="square" name="listingshort">
select mls_id,street_number,street_name,city
glvar_daily_bulk
</cfquery>
<cfloop query="listingshort">
<!---get data bing--->
<cfhttp url="http://dev.virtualearth.net/rest/v1/locations/us/nv/#listingshort.zip_code#/#listingshort. city#/#listingshort.street_number#%20#listingshort.street_name#?o=xml&key=agm3wr0ojspxyaje h6ws7p2kcckecqvq5hkrwefczccyoje3myvvirf_wzbetmeb" timeout = "2" method="get">
<cfset xbinglocation = xmlparse(cfhttp.filecontent)>
<cfset lat=xbinglocation.response.resourcesets.resourceset.resources.location.point.latitude.xml text>
<cfset long=xbinglocation.response.resourcesets.resourceset.resources.location.point.longitude.x mltext>
<!---update latitude , longitude fields--->
<cfquery datasource="square" name="addgeo">
update glvar_daily_bulk
set latitude = #lat#,
longitude = #long#
mls_id = #listingshort.mls_id#
</cfquery>
</cfloop>
More discussions in ColdFusion
adobe
Comments
Post a Comment