<%@ LANGUAGE="VBSCRIPT"%> <%OPTION EXPLICIT%> <%Response.Buffer = True%> <% Set objConn = Server.CreateObject ("ADODB.Connection") Set objRec = Server.CreateObject ("ADODB.Recordset") Set objRec2 = Server.CreateObject ("ADODB.Recordset") objConn.Open strconnect objRec.Open "cats", objConn, adOpenForwardOnly, adLockReadOnly, adCmdTable objRec2.Open "links", objConn, adOpenStatic, adLockReadOnly, adCmdTable %> <%=LSTitle%> <%Response.Write LSPageBody1%>

<% Dim arCatIDs() Redim arCatIDs(1) Dim arCatTitles() Redim arCatTitles(1) Dim i Dim ArraySize CatID = Request.QueryString("CatID") If Request.QueryString("CatID") = "" then CatID = 0 End If 'Create a recordset with the top level categories in it. strSQL = "SELECT * FROM Cats ORDER BY CatTitle ASC;" Set objRec = objConn.Execute (strSQL) Sub FillArray i = 0 'Loop until the top level category is found. DO UNTIL CatID = 0 'Create a filtered recordset with only one record. objRec.Filter = "CatID = " & CatID arCatIDs(i) = objRec("CatID") arCatTitles(i) = objRec("CatTitle") If NOT objRec("ParentID") = 0 then Redim Preserve arCatIDs(i+1) Redim Preserve arCatTitles(i+1) End If CatID = objRec("ParentID") i = i + 1 LOOP End Sub FillArray Response.Write FONT2 'It might be the top level in which case Home shouldn't be a link. If NOT Request.QueryString("CatID") = "" then If Request.QueryString("admin") = "" then Response.Write "Home >> " Else 'If this page is being used on the Add Category Admin Page then If Request.QueryString("admin") = "addcat" then Response.Write "Home >> " End If 'If this page is being used on the Delete Link Admin Page then If Request.QueryString("admin") = "dellink" then Response.Write "Home >> " End If End If Else Response.Write "Home >> " End If 'The array holds the information in the wrong order so read it backwards. For i = UBound(arCatIDs) to 0 Step - 1 If i = 0 then Response.Write arCatTitles(i) Else 'This is a stupid line of code. Remove it and see what happens to the first level of categories. If NOT arCatIDs(i) = "" then If Request.QueryString("admin") = "" then 'Write this if the page is being used on the display pages. Response.Write ""&arCatTitles(i)&" : " Else 'Write this if it is the add category admin page. If Request.QueryString("admin") = "addcat" then Response.Write ""&arCatTitles(i)&" : " End If 'Write this if it is the delete link admin page. If Request.QueryString("admin") = "dellink" then Response.Write ""&arCatTitles(i)&" : " End If End If End If End If Next Response.Write "" %>

<% Dim objRec3 Set objRec3 = Server.CreateObject ("ADODB.Recordset") objRec3.Open "cats", objConn, adOpenStatic, adLockReadOnly, adCmdTable CatID = Request.QueryString("CatID") If Request.QueryString("CatID") = "" then CatID = 0 End If 'Create a recordset with the top level categories in it. strSQL = "SELECT * FROM Cats WHERE ParentID= "& CatID &" ORDER BY CatTitle ASC;" set objRec = objConn.Execute (strSQL) Sub DisplayCats() Response.Write LSCatCells & FONT1 & "" If objRec.EOF then Response.Write " " Else 'Determin whether it is being used for Admin or not. If Request.QueryString("admin") = "" then%> &cattitle=<%=Replace(objRec("CatTitle"), " ", "+", 1)%>"><%=objRec("CatTitle")%> <%Else If Request.QueryString("admin") = "addcat" then%> &admin=addcat"><%=objRec("CatTitle")%> <%End If If Request.QueryString("admin") = "dellink" then%> &admin=dellink"><%=objRec("CatTitle")%> <%End If%> <%End If Response.Write FONT3 objRec2.Filter = "CatID="&objRec("CatID") 'Display amount of resources. If objRec2.RecordCount = 1 then Response.Write "(1 Resource) " Else Response.Write "(" & objRec2.RecordCount & " Resources) " End If objRec2.Filter = 0 objRec3.Filter = "ParentID="&objRec("CatID") 'Display the amount of categories. If objRec3.RecordCount = 1 then Response.Write "(1 Category)" Else Response.Write "(" & objRec3.RecordCount & " Categories)" End If objRec3.Filter = 0 Response.Write "" 'Display the descrition for the category if one exists. If NOT objRec("CatDesc") = "" then Response.Write "
" & FONT2 & objRec("CatDesc") End If objRec.MoveNext End If Response.Write "" End Sub If not objRec.EOF then 'Add the table HTML for the categories. Response.Write LSCatsTable 'Loop to step through the records in the categories recordset. Do Until objRec.EOF Response.Write "" DisplayCats DisplayCats Response.Write "" LOOP Response.Write "" Response.Write "
" End If 'Have a quick tidy up. If only house work was this easy. objRec3.Close Set objRec3 = Nothing %> <% If Request.QueryString("catid") = "" then CatID = 0 Else CatID = Request.QueryString("catid") End If CatTitle = Request.QueryString("cattitle") strSQL = "SELECT * FROM links WHERE CatID = " & CatID & " ORDER BY LinkName ASC; " Set objRec2 = objConn.Execute (strSQL) 'Output the body tag. Response.Write LSPageBody1 DO UNTIL objRec2.EOF 'If it is the delete links admin page it needs to be on a form. If Request.QueryString("admin") = "dellink" then%>

&admin=dellink"> <%End If 'Print out the HTML Response.Write LSResTable%> <%=LSResR1C1 & FONT4%><%= objRec2("LinkName") %> <%=LSResR1C2%> <%If Request.QueryString("admin") = "dellink" then%> "> <%Else%> " target="_blank">Visit Site<%End If%> <%=LSResR2a4C1 & FONT2%>Hits : <%= objRec2("LinkHits")%> since <%=objRec2("LinkAdded")%> <%=LSResR3C1 & FONT2%>URL : " target="_blank"><%= objRec2("LinkURL")%> <%=LSResR2a4C1 & FONT2 & objRec2("LinkDesc")%>

<% 'Move to the next record in the record set. objRec2.MoveNext LOOP 'Do this if the page is the delete link admin page. If Request.QueryString("admin") = "dellink" then 'Display a password box if required. If NOT Request.Cookies(""&Session.SessionID&"") = LSAdminPassword Then Response.Write FONT1 & "

Password :" Response.Write "

" End IF%>

<%End If%>
<%=PrintCredit%> <% 'Tidy up objRec.Close objRec2.Close objConn.Close Set objRec = Nothing Set objRec2 = Nothing Set objConn = Nothing %>