Avatar billede guzzie Nybegynder
20. august 2001 - 14:37 Der er 8 kommentarer og
1 løsning

Add up the values from a recordset

Hey There

I am attempting to add up the contents from my db
the colume name is called PrisIalt <-- setup as danish kr in the db
How would I go about adding these totals up and getting them displyed ??
My script looks like this
<% DO UNTIL wine_order_info.EOF %>
<tr><td><%=wine_order_info(\"PrisIalt\")%></td></tr>
<%
wine_order_info.MoveNext
LOOP
%>
Its PrisIalt that I would like to be added up and then displayed at the bottom of my asp page
If anyone knows how you would go about this it would be great
Thanks Guzzie
Avatar billede soenderup Nybegynder
20. august 2001 - 14:44 #1
<% DO UNTIL wine_order_info.EOF %>
<tr><td><%=wine_order_info(\"PrisIalt\")%></td></tr>
<%
total=wine_order_info(\"PrisIalt\")+wine_order_info(\"PrisIalt\")
wine_order_info.MoveNext
LOOP
%>
<tr><td>
Total:<%=total%>
</td></tr>
Avatar billede Slettet bruger
20. august 2001 - 14:49 #2
Just put this line in after <tr><td><%=wine_order_info(\"PrisIalt\")%></td></tr>:
<%
strPrice = strPrice+wine_order_info(\"PrisIalt\")
%>

And then

<%=strPrice%> At the buttom
Avatar billede Slettet bruger
20. august 2001 - 14:51 #3
Det var vi vist enige om :-)
Avatar billede guzzie Nybegynder
20. august 2001 - 15:31 #4
Hey there guys :)
both your answers did the same thing
if for example I have three prices then they I dont get a total I just get a print out
for example like this
175,00212,50325,00
as you can see this is just the prices next to each other and not added ?
any ideas
guzzies
Avatar billede soenderup Nybegynder
20. august 2001 - 15:37 #5
total=cint(wine_order_info(\"PrisIalt\"))+cint(wine_order_info(\"PrisIalt\"))


Avatar billede guzzie Nybegynder
20. august 2001 - 15:50 #6
hey soenderup
Still not right
I have 4 records
245,00
  85,00
1575,00
1300,00

when they get added up know I get one number but it is too big, I get 2600 back :(

Hmmm do you think it a problem with my commas
Guzzie
Avatar billede soenderup Nybegynder
20. august 2001 - 15:56 #7
try this...
clng instead of cint

total=clng(wine_order_info(\"PrisIalt\"))+clng(wine_order_info(\"PrisIalt\"))



Avatar billede guzzie Nybegynder
21. august 2001 - 12:34 #8
Hey There soenderup :)

I just tried your new suggestion how all it done was take the last record and times it by 2 ?

hmmmm
Guzzie :)
Avatar billede guzzie Nybegynder
21. august 2001 - 14:39 #9
Never mind thanks anyway guys but I got it done
buy myself
heres how i done it
    <%
    Connect.Open strDSN
    tracking = session(\"tracking_you\")
    Set wine_order_info = Connect.Execute(\"SELECT * FROM tracking WHERE tracking = \'\" & tracking & \"\'\")
    resultat = 0
%>
<% DO UNTIL wine_order_info.EOF %>
<% resultat = resultat + wine_order_info(\"PrisIalt\") %>
<%
wine_order_info.MoveNext
LOOP
%>
<tr><td>Result:<%=resultat%></td></tr>


Guzzie
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester