I open sourced the code for the object I use to create simple HTML tables. This is somewhat of a Swiss Army Knife object that can be used to create tables in multiple ways.
To understand the object you will want to look at both the source code and the demonstration page.
The object I use to produce forms is much more complicated. I am updating it for Forms 4.0.
NOTE: The program uses the sqlRow() function which encapsulates the PHP PDO object. It uses the htag() function which indents the output; so that my HTML is well formatted.