The code: http://ezdispatch.net/view_table_class.php
One of the things that I did for my most recent project, was a Table class, for building HTML Tables. It eliminates the ugly echo's etc that are so common for php-built tables, and it also eliminates a couple of the more common errors. Tags will always be in the correct order, all rows are adjusted to have the same number of cells (taking into account rowspans and colspans), and empty cells are filled with  's. It is FAR from perfect, but I thought I'd post it here anyway. Feel free to use it, and better yet...post back with updates/corrections/upgrades. There are instructions in the comments of the class itself on changing it to work with PHP 4. The class is attached.
It would be used like this:
$table = new Table(array('border'=>1));
$cur_row =& $table->add_head_row(array('style'=>'font-weight:bold;'));
$cur_row->add_cell(array('data'=>'Header 1'));
$cur_row->add_cell(array('data'=>'Header 2'));
$cur_row->add_cell(array('data'=>'Header 3'));
$cur_row->add_cell(array('data'=>'Header 4'));
$cur_row =& $table->add_row();
$cur_row->add_cell(array('data'=>'Row 1 - Col 1','rowspan'=>3));
$cur_row->add_cell(array('data'=>'Row 1 - Col 2','colspan'=>2));
$cur_row->add_cell(array('data'=>'Row 1 - Col 4'));
$cur_row =& $table->add_row();
$cur_row->add_cell(array('data'=>'Row 2 - Col 2'));
$cur_row->add_cell(array('data'=>'Row 2 - Col 4','rowspan'=>2, 'colspan'=>2));
$cur_row =& $table->add_row();
$cur_row->add_cell(array('data'=>'Row 3 - Col 3'));
$cur_row =& $table->add_row();
$cur_row->add_cell(array('data'=>'Row 4 - Col 1','colspan'=>4));
echo $table->get_table();
To test the error corrections, just remove or empty any cell, and watch it compensate!
And you can get as fancy as you want. The functions that build the tables, rows, and cells all take an associative array as a parameter, and anything you want can be set in there. For example, if you pass array('style'=>'padding-top:50px;','onmouseover'=>'alert("mouse is over")') to add_cell(), you will get a cell with a 50px top padding, and it will trigger an alert onmouse over. You can read through the comments in the code, and if you have any questions, feel free to ask!
The code: http://ezdispatch.net/view_table_class.php
My research as far as WHAT options to allow for each tag came from these links:
http://www.w3.org/TR/html4/index/elements.html
http://www.w3.org/TR/html4/index/attributes.html