I am new to ASP and I am attempting to design a sample Music Store ASP page. (see for an example)
If you pick a Genre from the list box...there is a "Browse Country Artists by Name" and A,B,C... links under it. This is what I want to do. I want a letter only to be linked if it has a matching artist under it. For example if there isn't a Country artist with a last name starting with Z I just want Z displayed with no link. But if there is a match the letter will be passed in the querystring to the next page to display all the artist under that letter. (that part isn't in my code yet)
I have the connection created fine and the recordset is created but how would you match the letter of the alphabet with the first letter.
I have a variable in the database called browseLetter that I am using to represent what each artist/group should be listed under. And I created an array to hold the alphabet but I am having a problem matching the two and moving through the recordset with creating exceptions or infinite loops..Any ideas???
Here is some of the code I tried last ( I haven't put the actual h ref tags in yet)
Dim strSQL
strSQL = "SELECT DISTINCT BrowseLetter FROM tblMain 1999 ORDER BY BrowseLetter"
Dim objRS2
Set objRS2 = Server.CreateObject("ADODB.Recordset"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
objRS2.Open strSQL, objConn, adOpenKeySet, adLockReadOnly, adCmdText
%>
<%
For x = 1 to 26
If objRS2("BrowseLetter"
= arrLetters(x-1) then
'The below is for testing only (HREF will be here)
Response.Write "link- " & arrLetters(x-1) & " -link<br>"
Else
Do while NOT objRS2.EOF
If objRS2("BrowseLetter"
<> arrLetters(x-1) then
'The below is for testing only (NO HREF will be here)
Response.Write "NOlink- " & arrLetters(x-1) & "- NOlink<br>"
objRS2.MoveNext
Else
'The below is for testing only (HREF will be here)
Response.Write "link2- " & arrLetters(x-1) & "- link2<br>"
objRS2.MoveLast
End if
Loop
End if
objRS2.MoveFirst
Next 'x
%>
<%
'Clean up and close the ADO Recordset
objRS2.Close
Set objRS2 = Nothing
objConn.Close
Set objConn = Nothing
%>
If you pick a Genre from the list box...there is a "Browse Country Artists by Name" and A,B,C... links under it. This is what I want to do. I want a letter only to be linked if it has a matching artist under it. For example if there isn't a Country artist with a last name starting with Z I just want Z displayed with no link. But if there is a match the letter will be passed in the querystring to the next page to display all the artist under that letter. (that part isn't in my code yet)
I have the connection created fine and the recordset is created but how would you match the letter of the alphabet with the first letter.
I have a variable in the database called browseLetter that I am using to represent what each artist/group should be listed under. And I created an array to hold the alphabet but I am having a problem matching the two and moving through the recordset with creating exceptions or infinite loops..Any ideas???
Here is some of the code I tried last ( I haven't put the actual h ref tags in yet)
Dim strSQL
strSQL = "SELECT DISTINCT BrowseLetter FROM tblMain 1999 ORDER BY BrowseLetter"
Dim objRS2
Set objRS2 = Server.CreateObject("ADODB.Recordset"
objRS2.Open strSQL, objConn, adOpenKeySet, adLockReadOnly, adCmdText
%>
<%
For x = 1 to 26
If objRS2("BrowseLetter"
'The below is for testing only (HREF will be here)
Response.Write "link- " & arrLetters(x-1) & " -link<br>"
Else
Do while NOT objRS2.EOF
If objRS2("BrowseLetter"
'The below is for testing only (NO HREF will be here)
Response.Write "NOlink- " & arrLetters(x-1) & "- NOlink<br>"
objRS2.MoveNext
Else
'The below is for testing only (HREF will be here)
Response.Write "link2- " & arrLetters(x-1) & "- link2<br>"
objRS2.MoveLast
End if
Loop
End if
objRS2.MoveFirst
Next 'x
%>
<%
'Clean up and close the ADO Recordset
objRS2.Close
Set objRS2 = Nothing
objConn.Close
Set objConn = Nothing
%>