In this second part of a five-part series on using Oracle's HTML Table with advanced queries, you'll learn how to create a simple table and more. This article is excerpted from chapter 34 of the book Beginning PHP and Oracle: From Novice to Professional, written by W. Jason Gilmore and Bob Bryla (Apress; ISBN: 1590597702).
At its most basic level, HTML_Table requires just a few commands to create a table. For instance, suppose you want to display an array of employee data as an HTML table. Listing 34-1 offers an introductory example that contains a simple CSS style sheet in conjunction withHTML_TABLEto format the employee data found in the$empl_reportarray.
Listing 34-1. Formatting Employee Data with HTML_Table (html_table_no_db.php)
Listng 34-1’s introducton mentions use of a CSS style sheet to tweak the table’s appearance (in this case, color, border, and padding). These styles are applied by using basic CSS principles of overriding the defaul table tag’s attributes with CSS-specific properties. However, when incorporating tables into more complex Web pages, using such a basic CSS strategy won’t be so easy. Fortunately, HTML_Table also supports the ability to tweak tables by passing in table-, header-, row-, and cell-specific attributes. This is accomplished with the HTML_Table() constructor for the table attributes, the SetRowAttributes() method for the headers and rows, and the setCellAttributes() method for cel-specific attributes. For each, you just pass in an associative array of attributes. For example, suppose you want to mark up the table with an id attribute called empl_data. You would instantiate the table like so: