"T.M. Sommers" <tms2 / mail.ptd.net> wrote in message news:<3D5875BF.72164C6E / mail.ptd.net>...
> Jason Underdown wrote:
> > 
> > I figured out how to build tables dynamically using methods in the CGI
> > class, but I can't figure out a way to add a header other than the
> > method I use below.  In the code below, I simply put the header row
> > into the array of rows generated by successive fetches from the
> > database.
> > 
> > The problem with the method I use below is that it forces me to use
> > <td> tags for the header columns when I would like to use <th> tags.
> > 
> > Any suggestions?
> > 
> 
> Did you try CGI#th?

I am fully aware of CGI#th.  Maybe I didn't explain myself well
enough.  What I want to be able to do is something like the following
code (which doesn't work):

cgi.table('border'=>'1') {
   cgi.tr { cgi.th{"ID"} + cgi.th{"First"} + cgi.th{"Last"} } +
   rows.collect { |row|
      cgi.tr {
         row.collect { |item|
            cgi.td { item }
         }
      }
   }
}

My previous code posting works, but notice that since the header row
gets generated by the same loop which creates the table body, the
CGI#td method is used to generate the header cells instead of CGI#th.