%@ 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 %>
<%
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 "