Print Page | Close Window

breadcrumb navigation trail

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=19686
Printed Date: 29 March 2026 at 7:40pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: breadcrumb navigation trail
Posted By: tjodalv
Subject: breadcrumb navigation trail
Date Posted: 03 May 2006 at 1:37pm
Hello
 
Can anyone help me with creating breadcrumb navigation trail from database table.
 
I have table tblCategory and that table have 3 fields:
 
id - unique identifier
sub_id - number
name - text
 
sub_id field holds the parent category id. How to create breadcrumb navigation trail. Google did not help me.
 
Thanks !
Tjodalv



Replies:
Posted By: lostcontrol
Date Posted: 03 May 2006 at 1:45pm
I wrote this for my website... hope it helps!

Function BreadCrumb

thisEndPage=PageID_of_currently_displayed_page (variable)
    thisStartPage=PageID_of_root (constant)
   
    Do Until thisEndPage=sub_id_of_root (constant)
        set getPage=rdCon.Execute("Select * From table Where PageID="&thisEndPage&"")
        If getPage.EOF=False Then
            If thisEndPage=currently_displayed_pageID Then
                BreadCrumb=getPage("PageName")
            Else
                BreadCrumb="<a href=""#"">" &getPage("PageName")&"</a> > "&BreadCrumb
            End If
        End If
        thisEndPage=getPage("ParentID")
        getPage.Close
        set getPage=Nothing
    Loop

End Function


Posted By: tjodalv
Date Posted: 03 May 2006 at 4:23pm
Thank you. That was very helpfull, it is working with simple modifications for my needs.
 

Function BreadCrumb
 strDBPath = "db1.mdb"
 
 Set dbConn = Server.CreateObject("ADODB.Connection")
 dbConn.Open "Provider=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & Server.MapPath(strDBPath)
 
 thisEndPage = Request.QueryString("cid")
 thisStartPage = 0
 varSeparator = " > "
 
 If Request.QueryString("cid") = "" Then
  Response.Write "<a href=""default.asp"">Home</a>"
 Else
  Response.Write "<a href=""default.asp"">Home</a>" & varSeparator
 End if
    
 Do Until thisEndPage = thisStartPage
 
  set getPage = dbConn.Execute("Select * From tblCategories Where id =" & thisEndPage & ";")
        
  If NOT getPage.EOF Then
  
   If thisEndPage = Request.QueryString("cid") Then
    BreadCrumb = getPage("name")
   Else
    BreadCrumb = "<a href=""default.asp?cid=" & getPage("id") & """>" & getPage("name") & "</a>" & varSeparator & BreadCrumb
   End If
   
  End If
        
  thisEndPage = getPage("sub_id")
  getPage.Close
  set getPage = Nothing
 Loop
End Function
 
Once again, thanks !!!


Posted By: lostcontrol
Date Posted: 04 May 2006 at 2:49pm
No worries



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net