I have a web application that I have built. I use 2 tables.
The first is a category table which is simply
I use a stored procedure to Display a breadcrumb type of navigation, and it works great.
What I'm wondering is what would I need to do to this stored procedure (pasted below) to make it work with another category table (the given example is for a photo gallery, I would like to re-use the same procedure for a links directory)
/****** Object: Stored Procedure dbo.gcDirNav Script Date: 2/7/2006 1:06:39 PM ******/
CREATE Procedure gcDirNav(@PageID nvarchar(255) = 0,@Delimiter varchar(5) = ' > ') As
Declare @BreadCrumb nvarchar(4000)
Set @BreadCrumb = ''
WHILE @PageID > 0
If (Select gCat From ModPicCats Where [gcID] = @PageID) <> 'Top'
Set @BreadCrumb = (Select '<a href="piccats.asp?pCat=' + @PageID + '">' + gCat + '</a>' From ModPicCats Where [gcID] = @PageID) + @Delimiter + @BreadCrumb
Set @PageID = (Select ParentID From ModPicCats Where [gcID] = @PageID) -- This iterates round until we get to the top (lcID = 0)
Set @BreadCrumb = '<a href="piccats.asp?pCat=0">Top</a>' + @Delimiter + @BreadCrumb
Set @BreadCrumb = Left(@BreadCrumb,Len(@BreadCrumb) - Len(@Delimiter))
Select @BreadCrumb As BreadCrumb