View Full Version : Average Score Count Script Error -Solved

03-03-2006, 04:49 PM

I'm trying to add a new row with a script that counts the average score for each competition to a table in a loop but I don't get it to work.
First of all I placed it outside the loop and that's the only place I can see it should be in so I need help on how to get it inside the loop.

The loop ends in row 81-82 and my new row (script) is placed in row 86-98

My other question probably solves itself if the first question is solved I guess
because the thing is that where I placed my new row made it just show up after the last table and I want it to show last in each table thatis looped out
from the database.

You can see how it looks here: http://www.monow.se/borg/sub/test.asp

Someone who could tell me what to do??

and here is the code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/javascript" src="/templates/menu.js"></script>
<link href="stylesheets/stylesheet1.css" rel="stylesheet" type="text/css" >
<link href="stylesheets/links.css" rel="stylesheet" type="text/css" >
<link rel="stylesheet" type="text/css" href="stylesheets/table.css">


<table width="695" height="0" border="0" cellspacing="5">
Sub createNewTableStart(endPrevTable)
if endPrevTable then response.write vbCrLf & "</table>" & vbCrLf & "<br />" & vbCrLf

<span style="padding-left: 28px;" class="rubrik"><b><%=objrs("CompName") %>&nbsp;<%= objrs("Course") %> (<%= objrs("Date") %>)</b></span>

<table align="center" border="1" style="border-collapse: collapse" bordercolor="1px solid #000000">
<tr bgcolor="#CDD5E4" style="font-weight: bold">
<% For I = 1 to 18 %>
<td width="30" align="center"><a href="top10.asp?Show=Top10&Lane=<%=I%>" target=""><%=I%></a></td>
<% Next %>
<td width="30" align="center">Tot</td>
End Sub

dim Conn, objrs, i, y, prevDate, currDate, strTot
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db/eb.mdb")
Set objrs = Conn.Execute("SELECT tbl_player.Namn, tbl_player.Efternamn, tbl_res.CompYear, tbl_res.Course, tbl_res.AMT1, tbl_res.AMT2, tbl_res.AMT3, tbl_res.AMT4, tbl_res.AMT5, tbl_res.AMT6, tbl_res.AMT7, tbl_res.AMT8, tbl_res.AMT9, tbl_res.AMT10, tbl_res.AMT11, tbl_res.AMT12, tbl_res.AMT13, tbl_res.AMT14, tbl_res.AMT15, tbl_res.AMT16, tbl_res.AMT17, tbl_res.AMT18, tbl_res.TOTAL, tbl_res.Date, tbl_res.CompName FROM tbl_player INNER JOIN tbl_res ON tbl_player.PlayerId=tbl_res.PlayerId WHERE tbl_res.Surface ='EB' ORDER BY tbl_res.Date, tbl_res.Varv")

while not objrs.BOF and not objrs.EOF
currDate = objrs("Date")
if IsEmpty(prevDate) then 'first iteration
elseif prevDate <> currDate then
end if
y = y + 1
If y Mod 2 = 0 Then
<tr bgcolor="#EEEEEE">
<% Else %>
<tr bgcolor="#FFFFFF">
<% End If %>

<% For I = 1 to 18 %>
<td align="center"><%=objrs("AMT" & I)%></td>
<% Next %>
<td align="center">
strTot = objrs("TOTAL")
if strTot < 20 then
response.write "<span class=""blueText"">"&strTot&"</span>"
elseif strTot < 25 then
response.write "<span class=""greenText"">"&strTot&"</span>"
elseif strTot < 30 then
response.write "<span class=""redText"">"&strTot&"</span>"
elseif strTot > 29 then
response.write "<span class=""blackText"">"&strTot&"</span>"
End if
response.write vbCrLf & "</td>" & vbCrLf & "</tr>" & vbCrLf
prevDate = currDate
if i=0 then 'empty recordset
response.write "<tr><td colspan=""19"">Det finns inga resultat!</td></tr>"
end if
<td colspan="18">&nbsp;</td>
<% set antalV = Conn.Execute("SELECT tbl_res.Comp_Name, Count(tbl_res.TOTAL) AS Ant FROM tbl_res GROUP BY tbl_res.Comp_Name HAVING tbl_res.Comp_Name='"&objrs("Comp_Name")&"'")%>
<% Set snitt = Conn.Execute("SELECT tbl_res.Comp_Name, Sum(tbl_res.TOTAL) AS Summa FROM tbl_res GROUP BY tbl_res.Comp_Name HAVING tbl_res.Comp_Name='"&objrs("Comp_Name")&"'")%>

<% inSvar1 = snitt("Summa")
inSvar2 = AntalV("Ant")
inSvar = Insvar1 / Insvar2
Response.Write formatnumber(Insvar,1)
'close and kill recordset/connection objects
set objrs = nothing
set Conn = nothing



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum