autogenrated table

S

Srijith Srijith

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>
 
S

Shashank Agarwal

babu said:
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 "<tr>\n"
columns.times do
print "<td></td>\n"
end
print "</tr>\n"
end
 
R

Raveendran Jazzez

HI Babu,

May be thiese lines helpful for u.

CODE:

class Table

def open_table
print "<table>"
end

def close_table
print "</table>\n"
end

def open_tr
print "<tr>"
end

def close_tr
print "</tr>"
end

def open_td
print "<td>"
end

def close_td
print "</td>"
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
http://raveendran.wordpress.com
 

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

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,663
Latest member
josh5959

Latest Threads

Top