Parsing data trouble


#1

Late in the day and I’ve hit a wall. Any help is appreciated.

Heres what I have:

<%
dbh =
DBI.connect(“dbi:blank:dbname=products;host=blank;blank”,“blank”,“blank”)

sth = dbh.execute(“SELECT * FROM products”)

while row = sth.fetch_array do
puts “

puts “Column Name : #{sth.column_names[0]}”
puts “Column Name : #{sth.column_names[1]}”
puts “Column Name : #{sth.column_names[2]}”
puts “

%>

Now, as long as I use puts “Column Name : #{sth.column_names[0]}” and
increment column_names by hand I get my data.

EX.
Array_Grid_Header =[“Column Name : #{sth.column_names[0]}” ,
“Column Name : #{sth.column_names[1]}”
,
“Column Name : #{sth.column_names[2]}”
,
“Column Name : #{sth.column_names[3]}”
,
“Column Name : #{sth.column_names[4]}”
];

Problem is, I need this to be dynamic so I can insert it into my array.
I am a C++ programmer and cannot figure out how to do this in RUBY.

Also, this is embedded Ruby code into JavaScript

what I need is something like this:

     for(var nCount = 0; nCount < <%=sth.column_names.size%>;

nCount++)
{
Array_Grid_Header +=
["<%=sth.column_names[nCount].upcase%>"];

     }

This would give me the Array in need, but it doesn’t like nCount.

See…<%=sth.column_names.size%> in my f’or loop’ produces 15.
I need fill Array_Grid_Header with the column names .

Thank you in advance.


#2

what I need is something like this:

     for(var nCount = 0; nCount < <%=sth.column_names.size%>;

nCount++)
{
Array_Grid_Header +=
["<%=sth.column_names[nCount].upcase%>"];

     }

try:
Array_Grid_Header += sth.column_names.collect{|c| c.upcase}


#3

Matt Gillooly wrote:

try:
Array_Grid_Header += sth.column_names.collect{|c| c.upcase}

Hey man. That was what I needed. I still don’t have the data parsed
correctly yet but I did a
alert(Array_Grid_Header); and can now see how the data is sitting.

Kudos dude!


#4

Matt Gillooly wrote:

try:
Array_Grid_Header += sth.column_names.collect{|c| c.upcase}

Hey man. That was what I needed. I still don’t have the data parsed
correctly yet but I did a
alert(Array_Grid_Header); and can now see how the data is sitting.

Kudos dude!