Autogenrated table

Please can any one for auto generated table,tr,td according to the query
result.
for ex:
columns:7
query size:3

        it should generate 7 <td> and 3 <tr>

babu nair wrote:

Please can any one for auto generated table,tr,td according to the query
result.
for ex:
columns:7
query size:3

        it should generate 7 <td> and 3 <tr>

You could use nested loops…

query_size.times do
print “

\n”
columns.times do
print “\n”
end
print “\n”
end

babu nair wrote:

Please can any one for auto generated table,tr,td according to the query
result.
for ex:
columns:7
query size:3

        it should generate 7 <td> and 3 <tr>

HI Babu,

May be thiese lines helpful for u.

CODE:

class Table

def open_table
print “


end

def close_table
print “

\n”
end

def open_tr
print “


end

def close_tr
print “


end

def open_td
print “


end

def close_td
print “


end

def create_row(number)
open_table
number.times do
open_tr
close_tr
end
close_table
end

def create_column(number)
open_table
number.times do
open_td
close_td
end
close_table
end

end

t=Table.new
print t.create_row(2)
print t.create_column(2)

Regards,
P.Raveendran

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs