Hi Paul

Do you have a datatype mismatch here:
<cfif GetColours.ColourID eq GetCartItems.ItemColour>

you might get some ideas from
http://www.macromedia.com/devnet/mx/dreamweaver/articles/build_shopping_cart
_pt3.html also

hope the above helps

Colm

-----Original Message-----
From: Paul Swingewood [mailto:[EMAIL PROTECTED]
Sent: 16 July 2004 16:33
To: [EMAIL PROTECTED]
Subject: Re: [ cf-dev ] More nuttiness


Thanks Duncan
I noticed it after I posted it.

I seem to be going round and round with this code though. I fix one thing
and something else dies ...:(

What I have now is sometimes it returns a colour sometimes it doesn't.
Theyre all in the database!
It will show the selected item only for the first item in the list ...
AGHHHH!

Can you have a look and maybe tell me where I am going wrong please....?

(Whole code follows)

<CFHEADER Name="Expires" Value="#Now()#">
<CFHEADER NAME="pragma" VALUE="no-cache">
<CFIF IsDefined("Cookie.CartID")>
        <!--- If there are 0 of any item, remove that item from the cart --->
        <CFQUERY  name="PurgeEmptyItems" datasource="#application.dsn#">
                DELETE FROM tblCartItems
                WHERE CartIDPK = '#Cookie.CartID#'
                AND Quantity = 0
        </cfquery>

        <!--- Get List of Cart Items --->
        <CFQUERY  NAME="GetCartItems" datasource="#application.dsn#">
                SELECT tblCartItems.ItemIDPK,
                        tblCartItems.ItemColour,
                        tblitems.partNum,
                        tblitems.itemName,
                        tblitems.itemCost,
                        tblCartItems.Quantity
                FROM  dbo.tblitems
                INNER JOIN
                        tblCartItems ON tblitems.itemID = tblCartItems.ItemIDPK
                WHERE itemID = ItemIDPK
                AND CartIDPK = '#Cookie.CartID#'
        </cfquery>



</cfif>

<div class="showitems">
<TABLE BORDER="0" CELLPADDING="5" CELLSPACING="1" bgcolour="#000000">
<tr><td colspan="6">Here's whats's currently in your basket (graphic
here)<p></p></td></tr>
<!--- These are just the column headings --->
<TR>

        <TD bgcolor ="##000000"><B>Item</B></TD>
        <TD BGCOLOR="##000000"><B>Description</B></TD>
        <td bgcolor ="##000000"><b>Size</b></td>
        <td bgcolor ="##000000"><b>Colour</b></td>
        <TD BGCOLOR="##000000"><B>Unit Price</B></TD>
        <TD BGCOLOR="##000000"><B>Quantity</B></TD>
        <TD BGCOLOR="##000000"><B>Subtotal</B></TD>
</TR>


<!--- If the shopping cart is empty, just say that. --->
<CFIF IsDefined("Cookie.CartID")>
        <CFIF NOT GetCartItems.RecordCount>

                <TR>
                        <TD BGCOLOR="#cc0000" COLSPAN="5" ALIGN="CENTER">
                        <I>(There are currently no items in your
                        shopping cart.)</I>
                        </TD>
                </TR>

        <!--- On the other hand, if the cart is not empty... --->
        <CFELSE>

                <!--- This form is called if quantities of the items are changed --->
                <cfoutput>
                <FORM
ACTION="changequants.cfm?CategoryID=#url.categoryID#&subcat=#url.subcat#"
METHOD="POST" name="currentcart">
                </cfoutput>
                <!--- This variable will be used to accumulate the total cost --->
                <CFSET TotalCost = 0>

                <!--- Now display the data for the current item --->
                <cfoutput query = "GetCartItems">
                        <cfset tblitemsItemID = GetCartItems.ItemIdPK>
                        <font color="black">#tblitemsItemID#</font><p></p>
                        <CFQUERY  NAME="GetColours" datasource="#application.dsn#">
                                SELECT tblItemColours.FKItemID,
                                        tblColours.Colour,
                                        tblcolours.colourID
                                FROM  tblColours
                                INNER JOIN tblItemColours
                                ON tblColours.ColourID = tblItemColours.Id
                                WHERE     (tblItemColours.FKItemID = #tblitemsItemId#)
                        </cfquery>

                        <TR>
                                <TD BGCOLOR="##cc0000">#PartNum#</TD>
                                <TD BGCOLOR="##cc0000">#ItemName#</TD>
                                <td BGCOLOR="##cc0000">
                                        <!---
                                        INSERT SIZE CODE HERE
                                        --->
                                </td>
                                <td BGCOLOR="##cc0000">
                                        <select 
name="selectColour#Replace(ItemIDPK,"-","_","ALL")#">
                                        <cfloop query="GetColours">
                                                        <cfif GetColours.ColourID eq 
GetCartItems.ItemColour> <!--- preselect
it --->
                                                                <option 
value="#GetColours.ColourID#"
selected>#GetColours.Colour#</option>
                                                        <cfelse>
                                                                <option 
value="#GetColours.ColourID#">#GetColours.Colour#</option>
                                                        </cfif>
                                                </cfloop>
                                        </select>
                                </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>

                <TR>
                        <TD COLSPAN="6" BGCOLOR="#cc0000" ALIGN="RIGHT">
                                <FONT FACE="Helvetica" SIZE="-1"><B>Total</B></FONT>
                        </TD>
                        <TD BGCOLOR="#cc0000" ALIGN="RIGHT">
                                <!--- Display the total cost --->
                    <CFOUTPUT>
                                        #lscurrencyFormat(TotalCost)#</FONT>
                                </CFOUTPUT>
                        </TD>
                </TR>
        </TABLE>
        <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=382>
                <TR>
                        <TD><BR><INPUT TYPE="SUBMIT" VALUE="Update Basket"></TD>
                        <TD ALIGN="RIGHT"><BR><INPUT TYPE="BUTTON" VALUE="Checkout"
onClick="location.href = 'checkout.cfm'"></TD>
                </TR>

                </FORM>

        </CFIF> <!--- is Cart empty --->
<CFELSE>
        <TR>
                <TD BGCOLOR="#FFcc66" COLSPAN="5" ALIGN="CENTER">
                <I>(There are currently no items in your
                shopping cart.)</I></FONT>
                </TD>
        </TR>
</CFIF> <!--- IS Cart defined --->

</TABLE>
</div>



--
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]


---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0429-2, 16/07/2004
Tested on: 16/07/2004 16:51:47
avast! is copyright (c) 2000-2003 ALWIL Software.
http://www.avast.com




-- 
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]

Reply via email to