%@ Language=VBScript %>
<%Option Explicit%>
<%
Dim PageName
PageName = "Catalogue"
%>
<%
Dim Category, SubCategory, RecordCount, PageCount, PageCounter, PageNo, ItemCount, ItemDescription
Dim SubCategoryHeader, SubCategoryMessage, ItemSide, PageCategory, PageSubCategory
Const ItemsPerPage = 10
If Request.Cookies("SessionID") = "" Then Response.Cookies("SessionID") = Session.SessionID
Category = Trim(Request("Category"))
SubCategory = Trim(Request("SubCategory"))
If Category = "" Then
Set Conn = Nothing
Response.Redirect "catalogue.asp"
End If
PageCategory = Split(Category, " - ")(0)
If Ubound(Split(Category, " - ")) = 1 Then
PageSubCategory = Split(Category, " - ")(1)
Else
PageSubCategory = ""
End If
If Trim(Request("PageNo")) <> "" Then
PageNo = Cint(Trim(Request("PageNo")))
Else
PageNo = 1
End If
Conn.open strConn
strSQL = "SELECT DISTINCT Category.Category "
strSQL = strSQL & "FROM Category INNER JOIN Product ON Category.Category = Product.Category "
strSQL = strSQL & "WHERE Category.Category = " & FormatSQLText(Category) & " "
strSQL = strSQL & "AND Product.Published <> 0"
Set RS = Server.CreateObject("ADODB.Recordset")
Set RS.ActiveConnection = Conn
RS.Open strSQL
If RS.EOF Then
Set RS = Nothing
Set Conn = Nothing
Response.Redirect "catalogue.asp"
End If
Set RS = Nothing
%>
Majestic Products - <%=PageName%>
<%
strSQL = "SELECT CategoryHeader, CategoryMessage FROM Category WHERE Category = " & FormatSQLText(Category) & " "
strSQL = strSQL & "AND (CategoryHeader IS NOT Null OR CategoryMessage IS NOT Null) "
Set RS = Server.CreateObject("ADODB.Recordset")
Set RS.ActiveConnection = Conn
RS.Open strSQL
If Not RS.EOF Then
%><%
SubCategoryHeader = RS("SubCategoryHeader")
If SubCategoryHeader <> "" Then
%><%=Replace(SubCategoryHeader, vbCrLf, " ")%> <%
End If
SubCategoryMessage = RS("SubCategoryMessage")
If SubCategoryMessage <> "" Then
%><%=Replace(SubCategoryMessage, vbCrLf, " ")%> <%
End If
%>
<%
End If
Set RS = Nothing
%>
<%
strSQL = "SELECT Product.* "
strSQL = strSQL & "FROM Category INNER JOIN Product ON Category.Category = Product.Category "
strSQL = strSQL & "WHERE Product.Published <> 0 And Product.Category = " & FormatSQLText(Category) & " "
strSQL = strSQL & "Order By Product.ProductName "
Set RS = Server.CreateObject("ADODB.Recordset")
Set RS.ActiveConnection = Conn
'RS.CursorType = adOpenStatic
'RS.CursorLocation = adUseServer
RS.CursorLocation = adUseClient
RS.Open strSQL
If Not RS.EOF Then
RS.PageSize = ItemsPerPage
RecordCount = RS.RecordCount
PageCount = RS.PageCount
RS.AbsolutePage = PageNo
%>
Found: <%=RecordCount%> Items
<%
If PageCount > 1 Then
%>
<%If PageNo = 1 Then%>
« Previous Page |
<%Else%>
« Previous Page |
<%End If%>
<%
For PageCounter = 1 TO PageCount
If PageNo = PageCounter Then
%>
<%=PageCounter%> |
<%
Else
%>
<%=PageCounter%> |
<%
End If
Next
%>
<%
If PageNo = PageCount Then
%>
Next Page »
<%
Else
%>
Next Page »
<%
End If
%>
<%
End If
%>
<%
ItemCount = 0
ItemSide = "Left"
While Not RS.EOF And ItemCount < ItemsPerPage
ItemCount = ItemCount + 1
If ItemSide = "Left" Then
%>
<%
End If
%>
<%
If ItemSide = "Left" Then
ItemSide = "Right"
Else
ItemSide = "Left"
%>
<%
End If
%>
<%
RS.MoveNext
Wend
%>
<%
If ItemSide = "Right" Then
%>
<%
End If
%>
<%
If PageCount > 1 Then
%>
Found: <%=RecordCount%> Items
<%If PageNo = 1 Then%>
« Previous Page |
<%Else%>
« Previous Page |
<%End If%>
<%
For PageCounter = 1 TO PageCount
If PageNo = PageCounter Then
%>
<%=PageCounter%> |
<%
Else
%>
<%=PageCounter%> |
<%
End If
Next
%>
<%
If PageNo = PageCount Then
%>
Next Page »
<%
Else
%>
Next Page »
<%
End If
%>
<%
End If
%>
<%Else%>
Items could not be found.
<%End If
Set RS = Nothing
%>
<%Set Conn = Nothing%>