hittade en kod i min dator som jag förmodligen INTE skrivit eftersom det inte är min kod struktur känns d som, hur som heslst denna kodsnutt listar ut huvud kategorier samt dess under kategori under huvudkategorin, dvs säga på följande sätt:
huvudkategori1
underkategori1.1
underkategori1.2
huvudkategori2
underkategori2.1
det jag undrar e hur man kan göra så att endast huvudkategorierna syns och när man sedan klickar på den så listas under kategorierna??
<!-- en massa includes här-->
<%
on error resume next
' set affiliate
if request.querystring("idAffiliate")<>"" and isNumeric(request.querystring("idAffiliate"))then
session("idAffiliate")= request.querystring("idAffiliate")
end if
dim mySQL, connTemp, rsTemp, pIdCategory, pCategoryDesc
' get child categories
mySQL="SELECT idCategory, categoryDesc, idParentCategory FROM categories WHERE idParentCategory=1 AND idCategory<>1 ORDER BY categoryDesc"
call getFromDatabase (mySql, rsTemp, "listCategoriesTree")
' no categories defined in the store
if rstemp.eof then
response.redirect "message.asp?message="&Server.Urlencode(dictLanguage.Item(Session("language")&"_listCategoriesTree_1") )
end if
%><!--#include file="header.asp"-->
<div align="left">
<br><img src="images/orange_arrow.gif" width="7" height="8">
<b><%response.write dictLanguage.Item(Session("language")&"_listCategoriesTree_2")%></b><br>
<%
' iterates through the child categories
do while not rstemp.eof
pIdCategory = rstemp("idCategory")
pCategoryDesc = rstemp("categoryDesc")
pIdParentCategory = rstemp("idParentCategory")
' check if there is another language defined to show for that category
switchCategoryLanguage session("language"), pIdCategory, pCategoryDesc
' if is child show the link to products, if not show the description
if isChildCategory(pIdCategory)=-1 then
response.write "<br><br><a href='listCategoriesAndProducts.asp?idCategory=" &pIdCategory& "'>"&pCategoryDesc&"</a>"
else
response.write "<br><br>"&pCategoryDesc
end if
' get child categories (recursive)
call getChildCategories(pIdCategory,1,0)
rstemp.moveNext
loop
call closeDb()
%>
<br>
<!--#include file="footer.asp"-->
<%
function getChildCategories(idParentCategory2, idPreviousParentCategory, tabs)
dim mySql2, rstemp2
mySql2="SELECT idCategory, categoryDesc, idParentCategory FROM categories WHERE idParentCategory=" &idParentCategory2&" ORDER BY categoryDesc"
call getFromDatabase (mySql2, rsTemp2, "listCategoriesTree")
do while not rstemp2.eof
pCategoryDesc2 =rstemp2("categoryDesc")
pIdCategory2 =rstemp2("idCategory")
switchCategoryLanguage session("language"), pIdCategory2, pCategoryDesc2
response.write "<br>"
if idPreviousParentCategory<>idParentCategory2 then
if idPreviousParentCategory>idParentCategory2 then
tabs = tabs-1
else
tabs = tabs+1
end if
idPreviousParentCategory = idParentCategory2
end if
for f=1 to tabs
response.write " "
next
if isChildCategory(pIdCategory2)=-1 then
response.write "<a href='listCategoriesAndProducts.asp?idCategory=" &pIdCategory2& "'>"&pCategoryDesc2&"</a>"
else
response.write pCategoryDesc2
end if
call getChildCategories(pIdCategory2, idPreviousParentCategory, tabs)
rstemp2.movenext
loop
end function
function isChildCategory(idCategory)
dim mySql3, rstemp3
mySQL3="SELECT idCategory FROM categories WHERE idParentCategory=" &idCategory
call getFromDatabase (mySql3, rsTemp3, "listCategoriesTree")
if rstemp3.eof then
isChildCategory=-1
else
isChildCategory=0
end if
end function
%>

