1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

New to ASP ....Help Needed Please!

Discussion in 'C#' started by chame, Apr 25, 2008.

  1. #1
    I haven’t a clue if what I am trying to do is displayed correctly in my code below. What I ultimately would like to do is: when all of the data is pulled from the database (they are stored in the same column but some of the entries are on different levels) example:

    Column entries: & Levels
    Airline 1
    Delta 2
    Passengers 3
    Baggage 4


    What I would like to do is when this information is displayed on my website each level has to descend properly such as this when called from the database:


    Airline
    • Delta
      o Passengers
      *Baggage​


    Here is the code that I have so far: The bolded section is what I have having the most problems with I’m not even sure if I am writing the code properly? What I want it to do is call all the data display the first item (“airline“) then save it & call the next item (“delta”) compare it to the first item, if the level numbers are different then save it under the first item (“airline”) etc… Does this make sense? I’m not sure where to start…. Any help would be sooo greatly appreciated. Thanks in Advance!!!

    <% 
    				
    				'get Recordset, objRS
    				dim objRS
    				set objRS = server.CreateObject("adodb.recordset")
    				
    				dim y
    				if request("goCat") = "Go" and request("txtSearchCategory") <> "" then					
    					y = FindLUCategoriesByName( request("txtSearchCategory"),(request("selDoc")), objRS)					
    				elseif request("showCat") <> "" then
    					y = GetLUCategories("", objRS)
    				elseif request ("selDoc")	<> "" then
    					y = GetLUCategoriesByLayer(objrs, request ("selDoc"), 2)
    				else
    					y = GetLUCategories("", objRS)						
    				end if	
    				
    			
    		 	[B]if objRS.eof then
    				if request ("selDoc")	<> "" then
    			 y = GetLUCategoriesByLayer (objrs, request ("selDoc"), 2)
    			  if layer >= 1 then
    			  	objRS.MoveNext 
    			  else 		
    			end if [/B]
    					
    		Do While Not objRS.EOF
    				
    			category = objrs("CATEGORY_NAME")
    			layer = objrs("LAYER_NUMBER")
    			documentTypeId = objrs("DOCUMENT_TYPE_ID")
    			categoryId = objrs("CATEGORY_ID")
    			parentCategoryId = objrs("PARENT_CATEGORY_ID")	
    				
    				   
    				    dim counter
    				   counter = 0
    				   loopCounter = loopCounter + 1
    					
    				   'Now loop through the recordset Fields
    				   For Each objField in objRS.Fields
    					 counter = counter + 1
    					 temp = objField.value
    					 
    					   if objField.name = "CATEGORY_ID" then
    						
    				  		elseif objField.name = "CATEGORY_NAME" then
    							if IsNull(objField.value) then
    								temp = "&nbsp;"
    														
    							end if
    				'First, display the TABLE header info:
    				Response.Write "<Table border=1 cellspacing=0 cellpadding=5 id=box>"
    			'Write the TR
    			Response.Write "<TR>"							
    						Response.Write "<TD>" 
    								Response.Write "<ul>"
    								Response.Write  "<a href=category.asp?edit=categoryId" & ">" & Category & "</a>"
    								Response.Write "<ul>"
    								Response.Write "<li>"  & Category &  "</li>"
    								Response.Write "</ul>"
    								Response.Write "</ul>"
    						Response.Write "</TD>"						
      									
    				  
    				Response.Write "<TD>" & "</TD>"
    				
    			 'Close the TR tag
    				   Response.Write "</TR>"				
    				'Close the table tag...
    				Response.Write "</TABLE>"
    				 	end if 				 
    				Next
    				  'Advance the recordset
    				   objRS.MoveNext				
    				Loop
    			end if 
    			
    		objRS.close
    	set objRS = nothing
    	end if 
    				%>
    Code (markup):
     
    chame, Apr 25, 2008 IP
  2. itcn

    itcn Well-Known Member

    Messages:
    795
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    118
    #2
    If I understand you correctly, why not try something like this (just pseudocode, and you'd need another if .. then to close the </ul>):

    
    SELECT airline, level FROM table ORDER BY level
    
    Dim thisLevel As Integer = 0
    Do While Not objRS.EOF
    	If objrs("level") <> thisLevel Then Response.Write "<ul>"
    	
    	Response.Write "<li>" & objrs("airline") & "</li>"
    	
    	thisLevel = objrs("level")
    Loop
    
    Code (markup):
     
    itcn, Apr 27, 2008 IP
  3. itcn

    itcn Well-Known Member

    Messages:
    795
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    118
    #3
    This code will create a new UL underneath the last one, nesting them deeper and deeper as the level changes. If you don't want to use ULs you could use padded TDs, etc.
     
    itcn, Apr 27, 2008 IP
  4. chame

    chame Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for the reply,

    but in the table there isn't a column for "order level" the function I am calling is a stored procedure and in the stored procedure each item is separated by levels.

    so basically I'm totally lost in how to even call the different levels.

    I was thinking of first calling every item from that column on the page then have some code that will say if it's the first layer display then if every other layer below that is greater than 1 display below 1 etc..

    but I haven't a clue how to do that.... .hope this makes sense?

    Thanks!
     
    chame, Apr 28, 2008 IP
  5. itcn

    itcn Well-Known Member

    Messages:
    795
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    118
    #5
    You want each level indented below the one above it, correct?
    Then maybe try this:

    <div style="padding-left: <%=10*yourLevelVariable%>px;">

    So for a level of 1, the div will be indented 10 pixels from the left, for level 2 the padding will be 20 pixels, for 3 it will be 30 pixels, etc.
     
    itcn, Apr 28, 2008 IP
  6. chame

    chame Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Well technically yes each level has to be indented below each other, but not all levels are the same.

    For example Airline would be assigned a level 1 delta level 2 passenger level 3 all this is done in the store procedure function that's being called from the database.

    So technically you can say that Airline is the parent delta is the child of airline passenger is the child or delta etc..

    I'm soo new to ASP and vbscript that I haven't a clue how to make this function the way it's suppose to.

    would seeing the store procedure for this function help?

    Thanks again for your help!
     
    chame, Apr 28, 2008 IP
  7. itcn

    itcn Well-Known Member

    Messages:
    795
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    118
    #7
    I guess I still don't understand what you are trying to do. Your example shows
    
    Airline
        Delta
             Passengers 
                  Baggage
    
    Code (markup):
    The code I gave you will do this. If this is not what you want, please describe exactly what you are trying to accomplish.
     
    itcn, Apr 28, 2008 IP
  8. chame

    chame Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hi... Thanks for your help! I figured it out :)
     
    chame, May 1, 2008 IP