SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Split and Recordset Looping Help!

    Hey Peeps,

    Does anyone know how I can loop an recordset whilst using the id to get information from an array?

    ie.

    Code:
    <%
    
    	string = split(Recordset2("String"))
    
    	Do While Not Recordset.EOF
    	
    		for i = 0 to ubound(string)
    		
    			response.write(string(Recordset("ID"))
    			
    		next
    		
    	Recordset.MoveNext
    	Loop
    	
    %>
    Im getting an error when I do it with mine that points no where near the array etc.

    Gav

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's the data look like? Is there a reason that you would need to store data in a db that has to be delimited?

  3. #3
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    tell you what it's for someone in here. but once it's cracked I can use the experience for further projects.

    I've amended his coding to this:

    Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <%
        Server.ScriptTimeout = 150
    	
    	Dim Connection
    	Set Connection = Server.CreateObject("ADODB.Connection")
    		Connection.Open "asp_test"
    		
    	Dim Personal_Options
    	Set Personal_Options = Server.CreateObject("ADODB.Recordset")
    		Personal_Options.Open "SELECT * FROM Personalization WHERE SubscriberID = '1'", Connection, 2, 2
    		
    	Dim TenderSubCategory
    	Set TenderSubCategory = Server.CreateObject("ADODB.Recordset")
    		TenderSubCategory.Open "SELECT * FROM TenderSubCategory", Connection, 2, 2
    		
    	Dim Personal_Selection(50), ColumnID, RowID, ColumnLimit
    	
    	Personal_Select = Split(Personal_Options("SelectedSubSections"),";")
    	ColumnID = 1
    	RowID = 1
    	ColumnLimit = 4
    	
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <% 
    
    Response.write("<table><tr>")
    
    Do While NOT TenderSubCategory.EOF
    '
    
    
    	IF ColumnID <= RowID * ColumnLimit THEN		
    		Response.write("<td>" & TenderSubCategory("SubCategoryId") & ": " & TenderSubCategory("SubCategoryName") & "</td><td><input type=""checkbox"" value=" & TenderSubCategory("SubCategoryId"))
    		
    		for i = 1 to ubound(Personal_Select)
    		
    		if Personal_Select(i) = TenderSubCategory("SubCategoryId") then
    			Response.write(" Checked")
    		end if
    		
    		Next
    		Response.write("></td>")
    
    		ColumnID = ColumnID + 1
    	ELSE
    		Response.write("</tr>")
    		Response.write("<tr>")
    		TenderSubCategory.MovePrevious()
    		RowID = RowID + 1
    	END IF
    	
    
    
    TenderSubCategory.MoveNext
    Loop
    
    
    
    Response.write("</tr></table>")
    %>
    
    </body>
    </html>
    Now the page still shows up, but it doesn't check the boxes as expected. What causes the problem here is that the numbers can be anything from 1 to the limit of the recordset.. So it could be 1;5;20;21;34;44;50 so what I want to do, is check the checkboxes that the user had previously checked and saved.

    If you are able to view it, which your currently online now, you can see the output at:

    http://82.39.11.101/voicecontacts/select.asp

    The numbers are the recordset id, the names are the title of the subscription, and of course the checkboxes values are the recordset id.

    Cheers

    Gavin

  4. #4
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol GREAT! got it working... simple Cint(Personal_Select(i)) got the ticks to appear

    Thanks anyways mate.

    Gav


Bookmarks

Posting Permissions

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