Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Location
    Houston, TX
    Posts
    34

    Unanswered: Array for Shopping Cart

    I'm new to using arrays and am having a problem with the array returning the wrong info.

    'Build Array
    Session("cartItem") = scartItem
    dim rsItem, sqlProductInfo
    sqlProductInfo = "SELECT * FROM products WHERE (products.catalogID=" & prodid & ")"

    'open connection - returns dbc as Active connection
    call openConn()
    Set rsItem = Server.CreateObject("ADODB.Recordset")
    rsItem.Open sqlProductInfo, dbc, adOpenForwardOnly,adLockReadOnly,adCmdText
    If Not rsItem.EOF Then
    'arrCart(cProductid,scartItem) = rsItem("catalogID")
    arrCart(cimagename,scartItem) = rsItem("cimageurl")
    arrCart(cProductname,scartItem) = rsItem("cname")
    arrCart(cSize,scartItem) = Cstr(size)
    arrCart(cQuantity,scartItem) = CInt(quantity)
    arrCart(cUnitPrice,scartItem) = rsItem("cprice")
    Session("MyCart") = arrCart
    End If
    rsItem.Close
    set rsItem = nothing
    call closeConn()

    'And then later call the array

    isubtotal = 0
    For i = 1 to scartItem
    strHTML = strHTML & "<tr bgColor=silver>"
    strHTML = strHTML & "<td><img src=" & q& "images/small/" & arrCart(cimagename,i) &q&"></td>"
    strHTML = strHTML & "<td>" & arrCart(cProductname,i) & "</td>"
    strHTML = strHTML & "<td>" & arrCart(cSize,i) & "</td>"
    strHTML = strHTML & "<td><input type="&q&"text"&q&" name="&q & "quantity" & CStr(i) & q &" value="&q & arrCart(cQuantity,i) &q&" size=3></td>"
    strHTML = strHTML & "<td>" & FormatCurrency(arrCart(cUnitPrice,i),2) & "</td>"
    strHTML = strHTML & "<td>" & FormatCurrency(arrCart(cUnitPrice,i) * arrCart(cQuantity,i),2) & "</td>"
    strHTML = strHTML & "</tr>"
    isubtotal = isubtotal + (arrCart(cUnitPrice,i) * arrCart(cQuantity,i))
    Next



    The problem is that the arrCart(cimagename,i) keeps showing the arrCart(cSize,i) data?

    Does anyone see what I am doing wrong?

    Thanks!

  2. #2
    Join Date
    Nov 2002
    Posts
    150

    Re: Array for Shopping Cart

    Where is your declaration for arrCart? What are the types of the referenced "c" variables (i.e. - cProductid)? Size and quantity are being loaded into the array but aren't from the recordset?

  3. #3
    Join Date
    Oct 2002
    Location
    Houston, TX
    Posts
    34
    I have attched the whole page. Some of the values are coming from a form that post to this page.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •