...

View Full Version : Populating a 2-D array from a database



pthompson2002
08-20-2002, 10:31 AM
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!

raf
08-20-2002, 12:51 PM
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 ?

allida77
08-20-2002, 02:06 PM
Use the .GetRows() method (http://www.devguru.com/Technologies/ado/quickref/recordset_getrows.html) . It will automatically put your rs into a 2d array.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum