www.webdeveloper.com
Results 1 to 3 of 3

Thread: Help with some VBcoding..

  1. #1
    Join Date
    Aug 2005
    Location
    USA
    Posts
    116

    Help with some VBcoding..

    Hey everyone,

    I was wondering if a experienced VBScripter might be able to help me with something I'm trying to figure out.

    What I'm trying to do is call product categories from a access DB, which I can do fine in a loop. And then have them display in a hyperlink and then click the hyperlinks call the page and then output the sub catagories to hyperlinks, etc, etc. till where at each indivdual product.

    Here is what I have so far.

    Code:
    <table cellspacing=0 cellpadding width=292 height=238 border=0>
    <tr><td align=center valign=middle>
    			
    	<%this_fullcat = replace(request("cat"),"%20%"," ")
    		this_id = request("id")
    		set rs = db.execute("SELECT * FROM catalog_categories WHERE parent='-' ORDER BY category")
    		while not rs.eof
    		category = rs("category")%>
    								
    <div  style="text-align: center; padding-top: 50pt;">
    	<a href="catalog-working.html?cat=<%=category%>\<%=subcategory%>" class="catnav"><%=category%></a>
    			</div>
    								
    	</div>
    								
    <% rs.movenext
       wend %>
    </td></tr>
    </table>
    I also have this code that calls the sub-catagory that I need to nest some how with that href tag I'm guessing?

    Code:
    <%
    set rs2 = db.execute("SELECT * FROM catalog_categories WHERE parent='" & replace(category,"'","''") & "' ORDER BY category")
    while not rs2.eof
    subcategory = rs2("category")
    id = rs2("id")	%>
    	<a href="catalog-new.html?cat=<%=category%>\<%=subcategory%>&id=<%=id%>" class="catnav"><%=subcategory%></a><br>
    <%
    	rs2.movenext
    	wend
    	%>
    Any assistance would be greatly appreicated.

  2. #2
    Join Date
    Dec 2003
    Location
    England, UK
    Posts
    432
    here's a bit of an example.

    Code:
    <%
    option explicit
    %>
    <html>
    <body>
    
    <%
    dim catalog_categoriesid
    catalog_categoriesid = cnum(request("id"))
    %>
    
    <table border=1>
    	<%
    	dim sql,rs,category
    	sql = "select id,category from catalog_categories where parent_catalog_categoriesid = " & catalog_categoriesid & " order by category"
    	
    	if runsql(sql,rs) then
    				
    		do while not rs.eof
    			%>
    			<tr><td><a href="cats.asp?id=<%=rs("id")%>"><%=rs("category")%></a></td></tr>
    			<% 
    			rs.movenext
       		loop
       		
       	end if
    	%>
    </table>
    
    </body>
    </html>
    
    <%
    
    'general routines below
    function runSQL(SQL,rs)
    
    	on error resume next
    	
    	dim myRs
    
    	set myRs = createobject("ADODB.recordset")
    	myRs.Open SQL,"Driver={SQL Native Client};Server=.\sqlexpress;Database=testdb;UID=sa;PWD=qwertyuiop;"
    	set rs = myRs
    	if err then
    		runSQL = false
    		response.write err.description
    	else
    		runSQL = true
    	end if
    
    end function
    
    
    
    
    function cnum(x)
    
    	on error resume next
    
    	cnum = clng(x)
    	if err then	
    		cnum = clng(0)		
    	end if
    
    end function
    
    %>

  3. #3
    Join Date
    Jan 2003
    Location
    USA
    Posts
    688
    And perhaps this may hopefully give you some ideas:

    Classic ASP Design Tips - QueryString
    http://www.bullschmidt.com/devtip-querystring.asp

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles