| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I'm a newbie. I have a SQL Server database which contains Category & Sub Category Tables. I need to make a ASP page which will show categories on the page with 3-4 sub-categories beneath them and they all should be clickable. I was try to code it. Below is my code. I need 3 records in one row and total of 3 colums to be displayed on the front page. <html> <head> <meta http-equiv="Content-Language" content="en-us"> </head> <body> <% Const SQLDSN = "ABC" Const SQLUser = "XXX" Const SQLPassword = "YYY" ' Create Objects Set Conn = Server.CreateObject("ADODB.Connection") 'Open the Connection Conn.Open SQLDSN, SQLUser, SQLPassword %> <% sql="SELECT CategoryID,CategoryDesc FROM Category" Set RS = Conn.Execute(sql) %> <table bgcolor="#FFCCCC" border="0" id="table1" style="font-family: Tahoma; font-size: 10pt; font-variant: small-caps; font-weight: bold" > <tr> <% Dim recordsInRow ' Dim recIndex recordsInRow=3 recIndex=0 Do While Not RS.EOF SQL1="SELECT SubCategoryDesc FROM SubCategory WHERE CategoryID='" & rs("CategoryID") & "'" Set RS1 = Conn.Execute(SQL1) 'check if need to add new row If (recIndex Mod recordsInRow)=0 Then 'need to add new row. first close previous row If recIndex>0 Then Response.Write("</tr>") Response.Write("<tr>") End If %> <% Response.Write("<td>"&rs("CategoryDesc")&"</td>")%> <% Do While Not RS1.EOF %> <p><% Response.Write("<td>"&RS1("SubCategoryDesc")&"</td>")%></p> <% RS1.MoveNext Loop %> <% recIndex=recIndex+1 rs.MoveNext Loop rs.Close %> </tr> </table> When I run this code without adding the sub-categories code, it looks fine but when I add the sub-category code, it becomes a mess. I would be grateful to you experts if you could help me in solving the issue. Best Regards, Thanks in advance. SMAH |
|
#2
|
||||
|
||||
|
search for my
drop down menu script
|
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Category Sub category Preview ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|