<table> Dim i, antal <code>Hjälp med Loop
<tr>
<td><font>Group1</font></td>
<td><font>Wins / Losses</font></td>
<td><font>Points</font></td>
</tr>
<%
Set MinCon = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.RecordSet")
MinCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath("db\ra3cup.mdb")
SQL = "SELECT * From league Where [group] = 1 ORDER BY pos"
rs.Open SQL, MinCon, 1, 2
Do until rs.eof
%>
<tr>
<td>" target="_parent"><%=rs("clan")%></td>
<td>Wins: <%=rs("v")%> / Losses: <%=rs("l")%></td>
<td>
'-----------------------------------------
'räknar ihop poäng
'-----------------------------------------
<%
Set objConnection=Server.CreateObject("ADODB.Connection")
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db/ra3cup.mdb")
strSQL="select sum(v) from league WHERE clan = '" & rs("clan") & "' group by v order by v"
Set objRS=objConnection.Execute(strSQL)
lngV=objRS(0)
objRS.Close
Set objRS=Nothing
objConnection.Close
Set objConnection=Nothing
%>
<%=FormatNumber((lngV)*3,0)%></td>
</tr>
<%
rs.movenext
Loop
%>
</table>
------------------------------------------
nu med problemet
hela den koden är för grupp1
går det att göra en kod som loopar igenom och skriver ut ALLA 8 grupper som jag har i min databas?
istället för att ha koden 8 gånger efter varandra och bara ändra sql'en?
hjälp snällaSv: Hjälp med Loop
antal = 8
For i = 1 To antal
SQL = "SELECT * From league Where [group] =" & i & " ORDER BY pos"
rs.Open SQL, MinCon, 1, 2
''
''
NextSv: Hjälp med Loop
<%
Dim I
Dim rs
Dim MinCon
Set MinCon = Server.CreateObject("ADODB.Connection")
MinCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath("db\ra3cup.mdb")
Set rs = Server.CreateObject("ADODB.RecordSet")
For I = 1 to 8
%>
<table>
<tr>
<td><font>Group1</font></td>
<td><font>Wins / Losses</font></td>
<td><font>Points</font></td>
</tr>
<%
rs.Open "SELECT Main.*, (SELECT Sum(v) FROM league AS Sub WHERE Sub.clan = Main.clan) As ClanPoints" & vbCrLf & _
"FROM league AS Main" & vbCrLf & _
"WHERE Main.[group] = " & I & vbCrLf & _
"ORDER BY Main.pos", MinCon
Do until rs.eof
%>
<tr>
<td>" target="_parent"><%=rs("clan")%></td>
<td>Wins: <%=rs("v")%> / Losses: <%=rs("l")%></td>
<td>
<%=FormatNumber(rs("ClanPoints") * 3, 0)%></td>
</tr>
<%
rs.movenext
Loop
rs.Close
%>
</table>
<%
Next
MinCon.Close
Set MinCon = Nothing
%>
</code>