And before we close here are few last tricks that come along with this very useful class.
One of the most common tasks when creating tables containing database output is alternating colors to make it easier to read. The HTML_Table class makes this easy to do, using the altRowAttributes function. Using our example from before the function works like this:
This will result in the rows switching colors with every row, starting with the second (as our first row is a header).
Outputting to HTML
Another useful feature is the toHtml() function which works much the same as the display function but instead returns the html rather than outputting directly. This is useful if you are building the table in a function or need to display the table in a place other than where you built it.
In parting, I hope that I have shown you the benefits of the HTML_Table class. There are several other functions which I felt were beyond the scope of this introduction but I very much encourage you to browse the code yourself and find them. I think you will find the documentation to be very well done.