[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

autogenrated table

Srijith Srijith

7/15/2008 11:44:00 AM

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>
--
Posted via http://www.ruby-....

2 Answers

Shashank Agarwal

7/15/2008 1:49:00 PM

0

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 "<tr>\n"
columns.times do
print "<td></td>\n"
end
print "</tr>\n"
end
--
Posted via http://www.ruby-....

Raveendran Jazzez

7/16/2008 10:16:00 AM

0

> 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 "<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.wor...

--
Posted via http://www.ruby-....