Hi Experts
I'm reusing the idea from netsmithcentral (
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/ASP/Q_22727207.html#a19589884) to try to create some menus depending on the page name.
The SQL for the script is:
SELECT tblStories.StoryID, tblStories.Menu_Item, tblStories.Title, tblStories.CategoryID, tblCategories.Category FROM tblStories INNER JOIN tblCategories ON tblStories.CategoryID = tblCategories.CategoryID WHERE tblStories.Menu_Item = True
and the code on the page is:
<%
Dim pageName
pageName = Request.ServerVariables("S
CRIPT_NAME
")
%>
<% If InStr(pageName, (rsMenu.Fields.Item("Categ
ory").Valu
e)) > 0 Then %>
<%=(rsMenu.Fields.Item("Ca
tegory").V
alue)%><br
/>
<%
While ((sideMenu__numRows <> 0) AND (NOT rsMenu.EOF))
%>
<%=(rsMenu.Fields.Item("Ti
tle").Valu
e)%><br />
<%
sideMenu__index=sideMenu__
index+1
sideMenu__numRows=sideMenu
__numRows-
1
rsMenu.MoveNext()
Wend
%>
<% End If %>
My problem is that it's not working.
If I alter the line '<% If InStr(pageName, (rsMenu.Fields.Item("Categ
ory").Valu
e)) > 0 Then %>' to '<% If InStr(pageName, "Stories") > 0 Then %>' (to reflect the page name is 'Stories.asp') the line '<%=(rsMenu.Fields.Item("C
ategory").
Value)%>' displays the last record in the table and the repeated region just lists all the records in the table.
How can I alter the code to:
a) reflect that '<%=(rsMenu.Fields.Item("C
ategory").
Value)%>' will display the correct category name based on the page filename without hard coding the page name into the code?
and
b) list only those records associated with the relevant category?
Many thanks in advance for your help.
Regards
Martin
Start Free Trial