Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 9th, 2004, 12:42 AM
syedhussaini syedhussaini is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 5 syedhussaini User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 35 sec
Reputation Power: 0
Question Category Sub category Preview ASP

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

Reply With Quote
  #2  
Old December 16th, 2004, 04:49 AM
guymclaren's Avatar
guymclaren guymclaren is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Nelspruit South Africa
Posts: 179 guymclaren User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 1 m 21 sec
Reputation Power: 4
search for my

drop down menu script

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Category Sub category Preview ASP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT