webForumDet fria alternativet

Loopa tabeller

ASPur ASP

15 svar · 270 visningar · startad av Alkvettern

Medlem sedan okt. 2002108 inlägg
Frågan#1

TJENA

Har en sida som hämtar uppgifter från en databas innehållande fotbollsmatcher.

Som det ser ut idag så listar jag alla matcher sorterade efter omgång.

Det jag vill ha är att alla matcher i omgång 1 ska listas men sen vill jag ha ett mellanrum innan matcherna i omgång 2 visas osv.

Hoppas ni förstår vad jag är ute efter.

SQL-strängen och tabellen ser ut så här.

strSQL = "Select * FROM tbl_matcher ORDER BY omgang"
 
<tr cellspacing="0" cellpadding="0">
<td width="50" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% Response.Write(oRS("omgang"))%>

</td>
<td width="20" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% Response.Write(oRS("hemmalag"))%>
</td>
<td width="25" bgcolor="<%=color%>"><center>-
</td>
<td width="20" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% Response.Write(oRS("bortalag"))%>
</td>
<td width="20" bgcolor="<%=color%>" width="2">

</td>
<td width="20" bgcolor="<%=color%>" align="right" width="5">
<font face="VERDANA" size="1">
<% Response.Write(oRS("hemmamal"))%>
</td>
<td width="20" bgcolor="<%=color%>" align="right" width="5">
-
</td>
<td width="20" bgcolor="<%=color%>" align="right" width="5">
<font face="VERDANA" size="1">
<% Response.Write(oRS("bortamal"))%>
</tr>

<%
oRS.MoveNext
Loop 
%>

Någon som har någon idé? (Tvivlar inte)

Medlem sedan dec. 200012 464 inlägg
#2
omg = 0
strSQL = "Select * FROM tbl_matcher ORDER BY omgang"
 
<tr cellspacing="0" cellpadding="0">
<td width="50" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% if omg <> 0 and clng(oRS("omgang")) <> omg then
          response.write "<br>"
          omg = clng(oRS("omgang"))
      end if
      Response.Write(oRS("omgang"))%>
Medlem sedan okt. 20005 273 inlägg
#3
[red]intSeperator = 0
strSQL = "Select * FROM tbl_matcher ORDER BY omgang"
If intSeperator <> intOmg Then 
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td colspan=""7""><hr noshade size=""1""></td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
End If
<tr cellspacing="0" cellpadding="0">
<td width="50" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% Response.Write(oRS("omgang"))%>

</td>
<td width="20" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% Response.Write(oRS("hemmalag"))%>
</td>
<td width="25" bgcolor="<%=color%>"><center>-
</td>
<td width="20" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% Response.Write(oRS("bortalag"))%>
</td>
<td width="20" bgcolor="<%=color%>" width="2">

</td>
<td width="20" bgcolor="<%=color%>" align="right" width="5">
<font face="VERDANA" size="1">
<% Response.Write(oRS("hemmamal"))%>
</td>
<td width="20" bgcolor="<%=color%>" align="right" width="5">
-
</td>
<td width="20" bgcolor="<%=color%>" align="right" width="5">
<font face="VERDANA" size="1">
<% Response.Write(oRS("bortamal"))%>
</tr>

<%
intSeperator = intOmg
oRS.MoveNext
Loop 
%>
[/red]

mvh icaaq

Du får nog anpassa colspan ...........

Medlem sedan okt. 2002108 inlägg
#4

Tack för ett snabbt svar, men tyvärr så händer ingen ting

det ser ut precis som förut.

Ungefär såhär.

1. Hemmalag - Bortalag 1 - 1
1. Hemmalag - Bortalag 3 - 2
2. Hemmalag - Bortalag 0 - 1

osv.

Medlem sedan okt. 20005 273 inlägg
#5

Vad heter ditt Recordset?

Medlem sedan okt. 2002108 inlägg
#6

Hjärnsläpp,, Vad menar du Is..?

Medlem sedan okt. 20005 273 inlägg
#7
[red]intSeperator = 0
strSQL = "Select * FROM tbl_matcher ORDER BY omgang"
If cLng(intSeperator) <> cLng(oRS("omgang")) Then 
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td colspan=""7""><hr noshade size=""1""></td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
End If
<tr cellspacing="0" cellpadding="0">
<td width="50" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% Response.Write(oRS("omgang"))%>

</td>
<td width="20" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% Response.Write(oRS("hemmalag"))%>
</td>
<td width="25" bgcolor="<%=color%>"><center>-
</td>
<td width="20" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% Response.Write(oRS("bortalag"))%>
</td>
<td width="20" bgcolor="<%=color%>" width="2">

</td>
<td width="20" bgcolor="<%=color%>" align="right" width="5">
<font face="VERDANA" size="1">
<% Response.Write(oRS("hemmamal"))%>
</td>
<td width="20" bgcolor="<%=color%>" align="right" width="5">
-
</td>
<td width="20" bgcolor="<%=color%>" align="right" width="5">
<font face="VERDANA" size="1">
<% Response.Write(oRS("bortamal"))%>
</tr>

<%
intSeperator = cLng(oRS("omgang")) 
oRS.MoveNext
Loop 
%>
[/red]

ska funka :)

Medlem sedan okt. 20005 273 inlägg
#8

JAg ville bara veta vad du kallade ditt recordset oRS, men jag såg det i ditt första inlägg

mvh icaaq

Medlem sedan okt. 2002108 inlägg
#9

Alkvettern skrev:

Tack för ett snabbt svar, men tyvärr så händer ingen ting

det ser ut precis som förut.

Ungefär såhär.

1. Hemmalag - Bortalag 1 - 1
1. Hemmalag - Bortalag 3 - 2
2. Hemmalag - Bortalag 0 - 1

osv.

Vad jag vill ha är

1. Hemmalag - Bortalag 1 - 1
1. Hemmalag - Bortalag 3 - 2

2. Hemmalag - Bortalag 0 - 1
2. Hemmalag - Bortalag 3 - 2

osv

När jag la in din ändring Ic så blev det en radbrytning mellan varje rad. Ledsen om jag uttryckte mig otydligt.

Mathias

Medlem sedan okt. 20005 273 inlägg
#10

visa hela din kod

Medlem sedan okt. 2002108 inlägg
#11

Här kommer koden

 strSQL = "Select * FROM tbl_matcher ORDER BY omgang"

Set oRS = oConn.Execute(strSQL)
%>
</head>

<body bgcolor="#FFFFFF" text="#000000" cellspacing="0" cellpadding="0" topmargin="25" leftmargin="25">
<table>
<tr>
<td>

<table align="left" bgcolor="#990000" cellspacing="0" cellpadding="0">
<tr cellspacing="0" cellpadding="0" bgcolor="#990000">
<td width="50">
<font face="VERDANA" size="1" color="white">
 Omgång
</td>
<td>
<font face="VERDANA" size="1" color="white">
 Hemmalag
</td>
<td width="2">
</td>
<td>
<font face="VERDANA" size="1" color="white">
 Bortalag
</td>
<td>
<font face="VERDANA" size="1" color="white">
</td>
<td colspan="3" align="right" width="20">
<font face="VERDANA" size="1" color="white">
 Resultat
</td>
</tr>

<% 
Do Until oRS.EOF 
nummer = nummer + 1 
If nummer Mod 2 = 0 then 
color = "white" 
Else 
color = "darkgray" 
End If  

%>

<tr cellspacing="0" cellpadding="0">
<td width="50" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% if omg <> 0 and clng(oRS("omgang")) <> omg then
          response.write "<br><br>"

          omg = clng(oRS("omgang"))
      end if
      
 Response.Write(oRS("omgang"))%>

</td>
<td width="20" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% Response.Write(oRS("hemmalag"))%>
</td>
<td width="25" bgcolor="<%=color%>"><center>-
</td>
<td width="20" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% Response.Write(oRS("bortalag"))%>
</td>
<td width="20" bgcolor="<%=color%>" width="2">

</td>
<td width="20" bgcolor="<%=color%>" align="right" width="5">
<font face="VERDANA" size="1">
<% Response.Write(oRS("hemmamal"))%>
</td>
<td width="20" bgcolor="<%=color%>" align="right" width="5">
-
</td>
<td width="20" bgcolor="<%=color%>" align="right" width="5">
<font face="VERDANA" size="1">
<% Response.Write(oRS("bortamal"))%>
</tr>

<%
oRS.MoveNext
Loop 
%>

<%
oRS.Close
Set oRS = Nothing
oConn.close 
Set oConn = Nothing
%>

Gör det någon visare?

Medlem sedan okt. 20005 273 inlägg
#12
[red] strSQL = "Select * FROM tbl_matcher ORDER BY omgang"

Set oRS = oConn.Execute(strSQL)
%>
</head>

<body bgcolor="#FFFFFF" text="#000000" cellspacing="0" cellpadding="0" topmargin="25" leftmargin="25">
<table>
<tr>
<td>

<table align="left" bgcolor="#990000" cellspacing="0" cellpadding="0">
<tr cellspacing="0" cellpadding="0" bgcolor="#990000">
<td width="50">
<font face="VERDANA" size="1" color="white">
 Omgång
</td>
<td>
<font face="VERDANA" size="1" color="white">
 Hemmalag
</td>
<td width="2">
</td>
<td>
<font face="VERDANA" size="1" color="white">
 Bortalag
</td>
<td>
<font face="VERDANA" size="1" color="white">
</td>
<td colspan="3" align="right" width="20">
<font face="VERDANA" size="1" color="white">
 Resultat
</td>
</tr>

<% 
[b]omg = 1[/b]
Do Until oRS.EOF 
nummer = nummer + 1 
If nummer Mod 2 = 0 then 
color = "white" 
Else 
color = "darkgray" 
End If  

%>

<tr cellspacing="0" cellpadding="0">
<td width="50" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% [b]if clng(oRS("omgang")) <> omg then[/b]
          response.write "<br><br>"

          omg = clng(oRS("omgang"))
      end if
      
 Response.Write(oRS("omgang"))%>

</td>
<td width="20" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% Response.Write(oRS("hemmalag"))%>
</td>
<td width="25" bgcolor="<%=color%>"><center>-
</td>
<td width="20" bgcolor="<%=color%>">
<font face="VERDANA" size="1">
<% Response.Write(oRS("bortalag"))%>
</td>
<td width="20" bgcolor="<%=color%>" width="2">

</td>
<td width="20" bgcolor="<%=color%>" align="right" width="5">
<font face="VERDANA" size="1">
<% Response.Write(oRS("hemmamal"))%>
</td>
<td width="20" bgcolor="<%=color%>" align="right" width="5">
-
</td>
<td width="20" bgcolor="<%=color%>" align="right" width="5">
<font face="VERDANA" size="1">
<% Response.Write(oRS("bortamal"))%>
</tr>

<%
oRS.MoveNext
Loop 
%>

<%
oRS.Close
Set oRS = Nothing
oConn.close 
Set oConn = Nothing
%>[/red]

mvh icaaq

Medlem sedan okt. 2002108 inlägg
#13

Det fungerar inte riktigt som det ska.

Det som händer är att omgångs nummret (oRS("Omgan")) flyttas
ner två radbrytningar, men hemmalag,bortalag o resultatet står kvar som förut

hoppas ni förstår

du kan se själv här

Mvh
Mathiashttp://www27.brinkster.com/alkvetternsik/visamatcher.asp

Medlem sedan maj 2002560 inlägg
#14

Är det inte bara att lägga till en tom post i utskriften?

[red]<%
	do while not oRS.eof
		response.write _
			"<tr cellspacing=""0"" cellpadding=""0"">" & _
			"<td width=""50"" bgcolor="" & color & ""><font face=""VERDANA"" size=""1"">" & oRS("omgang") & "</td>" & _
			"<td width=""20"" bgcolor="" & color & ""><font face="VERDANA" size="1">" & oRS("hemmalag") & "</td>" & _
			"<td width=""25"" bgcolor="" & color & ""><center>-</td>" & _
			"<td width=""20"" bgcolor="" & color & ""><font face=""VERDANA"" size=""1"">" & oRS("bortalag") & "</td>" & _
			"<td width=""20"" bgcolor="" & color & "" width=""2""></td>" & _
			"<td width=""20"" bgcolor="" & color & "" align=""right"" width=""5""><font face=""VERDANA"" size=""1"">" & oRS("hemmamal") & "</td>" & _
			"<td width=""20"" bgcolor="" & color & "" align=""right"" width=""5"">-</td>" & _
			"<td width=""20"" bgcolor="" & color & "" align=""right"" width=""5""><font face=""VERDANA"" size=""1"">" & oRS("bortamal") & "</td>" & _
			"</tr>"
		oRS.movenext
		[b]if not rs.eof then
			response.write "<tr [blue][i]height=""25""[/i][/blue]><td colspan=""8"" bgcolor=" & color & "></td></tr>"
		end if[/b]
	loop
%>[/red]

Eller har jag helt missuppfattat problemet?

Medlem sedan okt. 20005 273 inlägg
#15
[red]
...
...
<% 
omg = 1
Do Until oRS.EOF 
nummer = nummer + 1 
If nummer Mod 2 = 0 then 
color = "white" 
Else 
color = "darkgray" 
End If  
if clng(oRS("omgang")) <> omg then
Response.Write "<tr>" & vbCrLf
	Response.Write "<td colspan=""6""><hr noshade size=""1""></td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf

          omg = clng(oRS("omgang"))
end if

%>
<tr cellspacing="0" cellpadding="0">
<td width="50" bgcolor="<%=color%>">
<font face="VERDANA" size="1"><%=oRS("onmgang")%>
</td>
...
...
[/red]

Du kanske får ändra colspan värdet så att det passar, men detta kanske kan vara nått som passar.....

mvh icaaq

Medlem sedan okt. 2002108 inlägg
#16

TACK SÅ MYCKET icaaq, du har varit en klippa.

Det sista exemplet fungerade utmärkt. Nu ska jag bar göra några design justeringar.

Tack igen

Mathias

144 ms totalt · 3 externa anrop · v20260731065814-full.4bcf49fe
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
141 ms — hämta tråd, inlägg och bilagor (db)