26. oktober 2001 - 10:03Der er
5 kommentarer og 1 løsning
Udskriv struktur i recordset
Er der en som kan gennemskue hvordan jeg kan skriver flg. rs ud i nedenstående struktur:
ID | Parent ------------- 1 | 0 2 | 1 3 | 2 4 | 1
Det skal skrives sådan her ud: 1 (niveau 0) -2 (niveau 1) --3 (niveau 2) -4 (niveau 1)
Parent kolonnen angiver hvilket niveau den pågældende række hører hjemme på. Der kan selvfølgelig være uendeligt mange niveauer, så det skal være generelt...
noget i denne stil! SQL=\"Select* From Koder\" set rs=conn.execute(SQL) Response.Write \"<select name=Mandag size=1>\" Response.Write \"<OPTION SELECTED VALUE=\'\'>Velg Fravær</option>\" Do While Not rs.EOF Response.Write \"<option value=\'\" & rs(\"id\") & \"\'>\" & rs(\"parent\") & \"</option>\" rs.MoveNext Loop%>
Sub getSubfolders( id ) Set subRS = Conn.Execute(\"SELECT * FROM tabell WHERE Parent = \" & levelArr( UBOUND(levelArr) ) & \" ORDER BY ID ASC\") if not( subRS.EOF or subRS.BOF ) then
while not subRS.EOF ReDim preserve levelArr( UBOUND(levelArr) + 1 ) levelArr( UBOUND(levelArr) ) = subRS(\"ID\")
for i = 0 to UBOUND( levelArr ) response.write \"-\" next response.write tmpID & \"<br>\" if( tmpFolders ) then Call getSubFolders( tmpID ) end if
subRS.MoveNext counter = counter - 1 ReDim preserve levelArr( UBOUND(levelArr) - 1 ) ReDim preserve subfolderCountArr( UBOUND( subFolderCountArr ) - 1 ) wend end if end Sub
Sub countSubFolders() Set RSCount = Conn.Execute(\"SELECT COUNT(ID) AS count FROM tabell WHERE Parent = \" & levelArr( UBOUND( levelArr) ) ) ReDim preserve subFolderCountArr( UBOUND( subFolderCountArr ) + 1 ) subFolderCountArr( UBOUND( subFolderCountArr ) ) = RSCount(\"count\") if( counter = -1 ) then counter = subFolderCountArr( UBOUND( subFolderCountArr ) - 1 ) tmpCounter = counter end if end sub
function haveSubFolders( id ) Set tmpRS = Conn.Execute(\"SELECT COUNT(ID) AS count FROM tabell WHERE Parent = \" & id ) if( tmpRS(\"count\") > 0 ) then set tmpRS = nothing haveSubFolders = true else set tmpRS = nothing haveSubFolders = false end if end function
\' Close connection Conn.Close set conn = nothing %> </body> </html>
Function ShowReplies(bID, Conn) Dim RS SQL = \"SELECT id, parent FROM tabel WHERE ID = \" & bID & \" ORDER BY Dato\" Set RS = Conn.Execute(SQL) If NOT RS.EOF Then FoundSome = True %><ul><% End If Do While Not RS.EOF %><li><% = bRS(\"id\") %> (niveau <%=bRS(\"parent\")%></li><%
ShowReplies rs(\"BeskedID\"), Conn RS.MoveNext Loop If FoundSome Then
%></ul><%
End If
End Function
%>
Set bRS = Conn.Execute(\"SELECT id, parent FROM tabel parent = 0 ORDER BY id\")
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.