% @ Language = VBScript %>
<%
Option Explicit
With Response
.Buffer = True
.Expires = 0
.Clear
End With
Dim viewCategory : viewCategory = request("cat")
Dim viewSubCategory : viewSubCategory = request("sCat")
Dim c, r, sql : sql = ""
Dim displayField, productCatalogOptions, storeNavBar
if viewSubCategory = "" then
' there is no sub category query string
' so we are not displaying individual items
if viewCategory = "" then
' there is no category query string so
' let's display all the main categories
' displayField is the database field we
' will count and group below.
displayField = "categoryFull"
sql = "SELECT categoryFull, COUNT(categoryFull) AS majorCategories "
sql = sql & "FROM productCatalog GROUP BY categoryFull ORDER BY categoryFull;"
else
' we need to display the subCategories
' of the chosen category.
displayField = "subCategory"
sql = "SELECT subCategory, COUNT(subCategory) AS majorCategories "
sql = sql & "FROM productCatalog WHERE categoryFull = '" & viewCategory & "' "
sql = sql & "GROUP BY subCategory ORDER BY subCategory;"
end if
set c = server.createobject("adodb.connection")
c.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("./c1o1n3.mdb")
set r = c.Execute(sql)
Do While NOT r.BOF AND NOT r.EOF
' display the categories or sub categories depending
' on the amount of query strings. The categories or sub categories
' displayed will be clickable links.
if viewCategory = "" then
productCatalogOptions = productCatalogOptions & _
""
productCatalogOptions = productCatalogOptions & _
r(displayField) & "
" & vbCrLf
else
productCatalogOptions = productCatalogOptions & _
""
productCatalogOptions = productCatalogOptions & _
r(displayField) & "
" & vbCrLf
end if
r.Movenext
LOOP
r.close : c.close : set r = nothing : set c = nothing
else
' we are displaying individual items based on the
' category and sub category chosen by the client when they
' click the catalog links.
sql = "SELECT itemName, itemDesc, itemPrice, itemMisc, adminID FROM productCatalog WHERE categoryFull = '" & viewCategory & "' "
sql = sql & "AND subCategory = '" & viewSubCategory & "' ORDER BY itemName;"
set c = server.createobject("adodb.connection")
c.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("./c1o1n3.mdb")
set r = server.createobject("adodb.recordset")
r.open sql, c
on error resume next
Do While NOT r.BOF AND NOT r.EOF
' display the items in that sub category.
productCatalogOptions = productCatalogOptions & _
"" & r(0) & "
"
productCatalogOptions = productCatalogOptions & _
r(1) & "
" & "" & _
formatcurrency(r(2), 2) & "
"
productCatalogOptions = productCatalogOptions & _
r(3) & "
"
' don't forget the add to cart button.
' What good is a product catalog
' if you can't select items to purchase?
productCatalogOptions = productCatalogOptions & _
""
productCatalogOptions = productCatalogOptions & _
"add to cart
"
r.Movenext
LOOP
on error goto 0
r.close : c.close : set r = nothing : set c = nothing
end if
' now lets create a quick navigation bar for our catalog.
storeNavBar = ""
if viewCategory = "" AND viewSubCategory ="" then
' we are at home
storeNavBar = "home"
else
' we aren't at home so display the link to the main categories.
storeNavBar = "home > "
if viewCategory <> "" then
' if there is a category to view then...
if viewSubCategory <> "" then
' display the sub category and a link to the category
storeNavBar = storeNavBar & ""
storeNavBar = storeNavBar & viewCategory & _
" > " & viewSubCategory
else
' display the category only
storeNavBar = storeNavBar & viewCategory
end if
end if
end if
%>
|
![]() |
中文 Eng | Support | Comment |
IVE(HW) 網站地圖 |
|||
![]() |
|||