Is it posible, not to mention good practice to use the output from a query inside a loop? I am attempting to do that now and instead of getting the enitre list like I was expecting I get 1040 instances of the first page.
<!-- Query of the products in our database --->
<cfquery name="products" datasource='nwchicagocdsco
406'>
SELECT Products.ProductName
FROM Products
GROUP BY Products.ProductName;
</cfquery>
<cfset specialCharacters = " ()-">
<cfoutput query="products">
THIS SHOULD WORK ... SHOULD. <br>
#products.recordcount# <br>
<cfset QueryEnd = #products.recordcount#>
<cfset DrugName = 'Vioxx'>
<cfset NameLong = len(#ListFirst(Products.pr
oductname,
specialCha
racters)#)
>
<cfloop from="1" to="1040" index="i">
<!--- Grab the page --->
<cfhttp url="
http://mysite.com/productinfo.jhtml?particularDrug=#ListFirst(Products.productname,specialCharacters)#" resolveurl="no">
<hr>
<!--- Loop to find the url links on the grabbed page --->
<cfset PTR = findnocase("Dosage Forms", cfhttp.FileContent, 1)>
<cfset END = len(cfhttp.FileContent)>
<cfset EndOfLoop = FindnoCase('<table width="100%"', cfhttp.FileContent, ptr)>
#i# <br>
<!-- PTR = #PTR#, EOL = #EndOfLoop# <br> -->
<cfloop condition="PTR LT EndOfLoop and ptr GT 0">
<cfset hit = findnocase("#ListFirst(Pro
ducts.prod
uctname,sp
ecialChara
cters)#", cfhttp.FileContent, PTR)>
<!-- HIT = #hit# <br> -->
<cfif hit GT 0>
<cfset EndURL = findnocase('</td>', cfhttp.FileContent, hit)>
<cfset EndURL = (EndURL)>
<cfset HowLong = (EndURL - hit)>
<cfset Links = mid(cfhttp.FileContent, (hit), (HowLong))>
<!-- DEBUG INFO: Links: #endURL#, #HowLong#, -->#Links#,
<cfset hit2 = findnocase('000">', cfhttp.FileContent, PTR)>
<cfset EndCount = findnocase("</td>", cfhttp.FileContent, hit2)>
<cfset HowLongCount = (EndCount - hit2)>
<cfset Count = mid(cfhttp.FileContent, hit2 + 5, HowLongCount)>
#Count#,
<cfset Hit3 = findnocase("$", cfhttp.FileContent, PTR)>
<cfset EndPrice = FindnoCase("</td>", cfhttp.FileContent, hit3)>
<cfset HowLongPrice = (EndPrice - Hit3)>
<cfset Price = mid(cfhttp.FileContent, hit3, howlongprice)>
#Price# <BR>
<cfset PTR = hit + 1>
<cfelse>
DUMPED THE LOOP! <Br>
<cfset PTR = 0>
</cfif>
</cfloop>
<cfset Hit4 = findNoCase('Drug Manufacturer:</b>', cfhttp.filecontent, EndOfLoop)>
<cfset EndManufacturer = findnocase('<p><b>', cfhttp.FileContent, hit4)>
<cfset HowLongMan = (EndManufacturer - Hit4)>
<cfset Manufacturer = mid(cfhttp.FileContent, hit4, howlongman)>
#Manufacturer# <br>
<cfset Hit5 = findNoCase('Common Uses:</b>', cfhttp.FileContent, EndOFLoop)>
<cfset EndUses = FindNoCase('<p><b>', cfhttp.FileContent, Hit5)>
<cfset HowLongUses = (EndUses - Hit5)>
<cfset Uses = mid(cfhttp.FileContent, hit5, howlonguses)>
#Uses# <br>
<cfset i = (i + 1)>
</cfloop>
</cfoutput>
Thanks in advance!