Parsing data trouble

J

jplantz

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 "<br></br>"
puts "Column Name : #{sth.column_names[0]}"
puts "Column Name : #{sth.column_names[1]}"
puts "Column Name : #{sth.column_names[2]}"
puts "<br></br>"

%>


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.
 
M

Matt Gillooly

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}
 
J

jplantz

Matt said:
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}



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!
 
J

jplantz

Matt said:
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}



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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,222
Messages
2,571,141
Members
47,756
Latest member
JulienneY0

Latest Threads

Top