Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

generating tables and lists dynamically using cgi.pm 1

Status
Not open for further replies.

ailse

Programmer
Jan 20, 2004
79
GB
Hi -

I have a cgi program that returns two sets of results to the user. At the moment they are simply printed in the browser, but I would like to know how to format them so they appear in tables and lists as required.

The first result is a simple array of elements - I want to list these elements as a bullet list. The second set of results is an array of arrays, so I would like each array in the array to be returned as a row of a table, with each individual element appearing in a single cell...

any advice greatly appreciated :)
 
BASIC IDEA

#a list

print "<ul>";

foreach $item (@data){
print "<li>$item";
}
print "</ul>";

#a table

print "<table>";

foreach $item (@data){ #ROWS
print "<tr>";
foreach $item2 (@data2){
print "<td>$item2</td>"; #COLUMNS
}
print "<tr>";
}
print "</table>";
 
chris -- cheers for that, but I am using the object oriented method of cgi.pm - can I still use similar code to create the list and table?

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top