Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2002
    Location
    Ipswich
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Populating a 2-D array from a database

    Hello all, me again.

    I have realised I need a 2-D instead of the 1-D array (below) for ther est of task to work.
    My question is how can I change the code below to make it a 2-D array.

    ------------------------------

    <script language = "JavaScript">
    <!-- //Begin Hide
    //Create the Array

    var messages=new Array(<%=rsCount("MaxCount")%>);

    //Populate the Array
    <%
    i = 0
    do while NOT rsBroadcast.EOF
    %>
    messages[<%=i%>]="<font color=orange><%=rsBroadcast("Title")%></font>"
    <%
    i = i + 1
    rsBroadcast.MoveNext
    Loop
    %>
    // End Hide -->
    </script>

    -------------------------------------

    the other 'column' in the array is going to be the "message" column from the same table as the title of that helps.

    cheers

    Pete

    PS. this forum is fantastic for responses, I can't believe how everyone responds so quickly!

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    maybe a stupid question, buth why are you trying to populate an array with data from a recordset (which is itself an array)

    in your title, i read populating ... from a database so i assume you could use a select-query to generate a recordset that contains those two variables ? no ?

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use the .GetRows() method . It will automatically put your rs into a 2d array.


  •  

    Posting Permissions

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