the problem is with your getcartitems.itemsitemsize. i'd guess you're
basically selecting the items and the various sizes/colours they are
available in, in the same query. however, this is returning multiple rows
for each item, i.e. the colour red is available for each shoe, so if there
are 3 shoes, the colour red will show up three times.
you either need to use a bit of SELECT DISTINCT, or to use seperate queries
for getting the colours and sizes (what I'd do).
"Paul Swingewood"
<[EMAIL PROTECTED] To: [EMAIL PROTECTED]
tmail.com> cc:
Subject: [ cf-dev ] loop the loop
loopiness
16/07/2004 11:21
Please respond to
dev
Can anyone help me with this one please.
I have the following code ....
<CFOUTPUT QUERY="GetCartItems">
<TR>
<TD BGCOLOR="##cc0000">
#PartNum#</TD>
<TD BGCOLOR="##cc0000">
#ItemName#</TD>
<td BGCOLOR="##cc0000">
<cfif
GetCartItems.ItemsItemSize eq "">
N/A
<cfelse>
<select name
="selectSize#Replace(ItemIDPK,"-","_","ALL")#">
<cfloop index
= "ListElementSize" list = "
#ValueList(GetCartItems.ItemsItemSize)#">
<cfif #ListElementsIZE# eq GetCartItems.CartItemsItemSize> <!---
preselect
it --->
<option value="#ListElementSize#"
selected>#ListElementSize#</option>
<cfelse>
<option value="#ListElementSize#">#ListElementSize#</option>
</cfif>
</cfloop>
</select>
</cfif>
</td>
<td BGCOLOR="##cc0000">
<cfif
GetCartItems.ItemsItemColour eq "">
N/A
<cfelse>
<select name
="selectColour#Replace(ItemIDPK,"-","_","ALL")#">
<cfloop index
= "ListElementColour" list =
"#ValueList(GetCartItems.ItemsItemColour)#">
<cfif #ListElementColour# eq GetCartItems.CartItemsItemColour> <!---
preselect it --->
<option value="#ListElementColour#"
selected>#ListElementColour#</option>
<cfelse>
<option value="#ListElementColour#">#ListElementColour#</option>
</cfif>
</cfloop>
</select>
</cfif>
</td>
<td ALIGN="RIGHT" bgcolor="
##cc0000">#lscurrencyFormat(ItemCost)#</TD>
<td bgcolor="##cc0000">
<input type="Text" name
="Quantity#Replace(ItemIDPK,"-","_","ALL")#"
value="#Quantity#" align="RIGHT" size="3">
</TD>
<TD BGCOLOR="##cc0000" ALIGN
="RIGHT">
#lscurrencyFormat(ItemCost * Quantity)#
</TD>
</TR>
<!--- Add cost of current item(s) to total
cost --->
<CFSET TotalCost = TotalCost +
(GetCartItems.ItemCost *
GetCartItems.Quantity)>
</CFOUTPUT>
All seems to work ok except that when I add more and more items to the cart
the select drop down lists apend whats in the list to the previous list
each
time.
YOu can see this happening by going here http://217.43.93.212/store select
footwear (stilettos & platforms have pics) select an item put this in my
basket. Do this a cople of times and then look at the size & colour drop
down lists. - Sorry about this but its the best way to explain whats
happening.
Back to the code ..
The tblitems has size = 1,2,3,4,5,6,7,8,9 colour = red,white,blue
I loop over the list and check to see if the item is already in the cart
(tblcartitems) if it is select it if not just show the list. Why is the
list
being appended to each time? Nothing is being written to the database that
shouldn't (ive checked)....
Regards - Paul (BTW its not my colour scheme and yes I hate it ...)
--
These lists are syncronised with the CFDeveloper forum at
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided
by activepdf.com*
*Forums provided by fusetalk.com* :: *ProWorkFlow provided by
proworkflow.com*
*Tutorials provided by helmguru.com* :: *Lists hosted by
gradwell.com*
To unsubscribe, e-mail: [EMAIL PROTECTED]
--
These lists are syncronised with the CFDeveloper forum at
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by
activepdf.com*
*Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
*Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*
To unsubscribe, e-mail: [EMAIL PROTECTED]