morestar 0 Newbie Poster

Hi everyone. This is my first time here. I thank everyone for their help and support.

I don't have much of a problem but I have some code that I want to clean up and I'm fairly new at coldfusion. I believe there is a way I can clean up my code with respect to this one function I have and/or make the function run faster. I don't even know if it's actually a function but here it is:

<!--- Set list of items to display for this category --->
<cfset getlist = ArrayNew(1)>
<cfset str = "">    
<cfset x = 1>

<cfquery name="item" datasource="#request.dsn#">
    select productnum from gift1to100 where gifttype = '#showlist#' and currency = #currency.currency_id#;
</cfquery>
<cfloop query="item">            
    <cfset getlist[x] = #item.productnum#>        
    <cfif x eq item.recordcount>        
        <cfset str = str & getlist[x]>
    <cfelse>
        <cfset str = str & getlist[x] & ",">
    </cfif>
    <cfset x = x + 1>        
</cfloop>
<cfset itemlist = str>

<!--- get items from db --->
<cfquery name="item" datasource="#request.dsn#">
    select productdescription.product_name, product.description_id, product.product_no, productprice.price 
    from product, productdescription, productprice
    where
        product.description_id = productdescription.description_id 
        and product.product_no = productprice.product_no
        and productprice.currency_id = #currency.currency_id# 
        and productprice.franchise_id = 0    
        and (product.product_no = 0<cfloop list="#itemlist#" index="i"> or product.product_no = #i#</cfloop>);
</cfquery>

So basically I have a table with a product number field. My overall desire was to append the product numbers to the 'itemlist' variable and then have each product number taken from another table based on the 'gifttype' and 'currency'.

Is there a faster way? If you need more information please let me know.

Thanks always.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.