Cleaning up my code.

Reply

Join Date: May 2007
Posts: 1
Reputation: morestar is an unknown quantity at this point 
Solved Threads: 0
morestar morestar is offline Offline
Newbie Poster

Cleaning up my code.

 
0
  #1
May 23rd, 2007
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:

  1. <!--- Set list of items to display for this category --->
  2. <cfset getlist = ArrayNew(1)>
  3. <cfset str = "">
  4. <cfset x = 1>
  5.  
  6. <cfquery name="item" datasource="#request.dsn#">
  7. select productnum from gift1to100 where gifttype = '#showlist#' and currency = #currency.currency_id#;
  8. </cfquery>
  9. <cfloop query="item">
  10. <cfset getlist[x] = #item.productnum#>
  11. <cfif x eq item.recordcount>
  12. <cfset str = str & getlist[x]>
  13. <cfelse>
  14. <cfset str = str & getlist[x] & ",">
  15. </cfif>
  16. <cfset x = x + 1>
  17. </cfloop>
  18. <cfset itemlist = str>
  19.  
  20. <!--- get items from db --->
  21. <cfquery name="item" datasource="#request.dsn#">
  22. select productdescription.product_name, product.description_id, product.product_no, productprice.price
  23. from product, productdescription, productprice
  24. where
  25. product.description_id = productdescription.description_id
  26. and product.product_no = productprice.product_no
  27. and productprice.currency_id = #currency.currency_id#
  28. and productprice.franchise_id = 0
  29. and (product.product_no = 0<cfloop list="#itemlist#" index="i"> or product.product_no = #i#</cfloop>);
  30. </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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC