PHPBuilder - Using PEAR's HTML_Table Class Page 3

RSS Twitter
Articles Html

Using PEAR's HTML_Table Class - Page 3

by: Andy Nortrup
August 18, 2003

Changing the Look of Things

Now that we have learned to build tables with the class, let us take a look at how to spice them up a bit. To do this we have a wide selection of tools which allow us to change the way that the table looks on 3 levels:
  1. Table Level
  2. Row or Column Level
  3. Cell Level
1. At the table level we manipulate properties with either the setAllAttibutes or the updateAllAttributes functions. The only difference between these two functions is that updateAllAttributes will add attributes to your table, leaving current attributes in place while setAllAttributes will replace whatever has been previously set. The usage of these two functions is as follows:

Where $properties is either a string or an associative array as discussed previously.
2. To manipulate the attributes of rows and columns we use the following functions:


The use of these functions is fairly straight forward but there is one important thing to remember. First the $row and $col attributes are the numbers of the row or column that you wish to change. Numbering of rows and columns starts at 0, so in order to make the first row of the table have a background color of blue, you would use the following code segment:

= array(bgcolor=>#0000FF);
3. In order to set attributes of individual cells we would use one of these two functions:

Both functions are very straight forward, simply specify the cell location by row and column number then specify the attributes. Again, row and column numbers start at 0.

« Previous Page
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Andy Nortrup



(Maximum characters: 1200). You have characters left.