ASP Sum or Total HELP

Discussion in 'C#' started by james6380, Nov 5, 2007.

  1. #1
    Hi there I have a database setup and the results come out as

    Product 1: Shorts
    Size: M
    Price: £2.99

    Product 2: T-Shirt
    Size: XL
    Price: £3.99


    Total: "TOTAL HERE"

    What I need to do is total these up

    The Cells are called:
    <%response.write(request.form("Product"))%>
    <%response.write(request.form("Size"))%>
    <%response.write(request.form("Price"))%>


    Please can someone help me thanks
     
    james6380, Nov 5, 2007 IP
  2. Link.ezer.com

    Link.ezer.com Peon

    Messages:
    647
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Example Code:

    id product size price
    1 Shorts M 2.99
    2 T-Short XL 3.99
    3 Shorts M 5.3
    <%
    ' code also saved at http://3w.ezer.com/sql/select/sum.asp
    query=request("query") 'ex: query="M"
    fieldQuery=request("fieldQuery") 'ex: fieldQuery="Size"

    DIM SQL, RS, conn
    SQL="SELECT SUM(price) AS sumTotal from TB where "&fieldQuery&"='"&query&"' "
    Set RS = Server.CreateObject("ADODB.Recordset")
    RS.Open SQL,conn

    sumTotal= rs("sumTotal")
    rs.close

    response.write sumTotal

    %>

    result: 8.29
     
    Link.ezer.com, Nov 6, 2007 IP