Page 489 - Beginning PHP 5.3
P. 489

Chapter 15: Making Your Job Easier with PEAR

                             Method                                Description
                               addRow( $ contents , $ attrs ,        Adds a row of cells to the table.
                           $ type , $ inTR , $ body  )
                                                                       $ contents  holds the row data as an indexed array,

                                                                 where each element is the data for a single cell. The
                                                                 optional $ attrs  argument contains attributes to


                                                                 apply to the row, and the optional   type  argument
                                                                                            $

                                                                 can be either    “ th ”   (for header cells) or   “ td ”   (for
                                                                 data cells)  —  the default is    “ td ”.   Set the optional
                                                                   $ inTR  argument to  true  to apply the attributes to

                                                                 the   tr  element rather than the  td/th  elements (the
                                                                 default). Finally, if you ’ re using   tbody  elements,


                                                                 specify the   tbody  group number as the  $ body
                                                                 argument. (Use  addBody()  to add a new table body  —
                                                                   see the online documentation for details.)
                                                     ,
                                             ,
                               addCol( $ contents  $ attrs           Adds a column of cells. The parameters work in the
                           $ type  $ body  )                     same way as   addRow() .
                                 ,
                               altRowAttributes( $ start ,           Allows you to set different attributes for every other
                           $ attrs1  $ attrs2  $ inTR  $ body  )     table row, so you can create alternating row styles.
                                   ,
                                                   ,
                                            ,

                                                                 $ start  is the index of the row to start alternating,
                                                                 and   $ attrs1   and  $ attrs2   are associative arrays or
                                                                 strings holding the attributes to apply to each
                                                                 alternate row. The optional   $ inTR   and  $ body


                                                                 arguments work in the same way as those in
                                                                   addRow() .
                                                 ,
                               setCellContents( $ row  $ col         Allows you to set or change the contents of an
                                                       ,
                           $ contents  $ type  $ body  )         arbitrary cell in the table. The cell is specified by
                                     ,
                                            ,
                                                                   $ row   and  $ col   (numeric indices starting from zero),
                                                                 and   $ contents  contains the string to place in the

                                                                 cell. The optional   $ type  and  $ body   arguments work

                                                                 in the same way as those in   addRow() .
                                                   ,
                               setHeaderContents( $ row  $ col ,       Allows you to set or change a header cell. Works in a
                            $ contents  $ body  )                similar way to   setCellContents() .
                                     ,

                               setAutoGrow( $ grow  $ body  )       With  $ grow  set to  true , auto - grow is enabled. This
                                              ,
                                                                 means that, whenever you use   setCellContents()
                                                                 or   setHeaderContents()  to populate non - existent
                                                                 cells, empty cells are created as necessary to fill in
                                                                 the gap between the existing cells and the new cells.
                                                                 The default value for   $ grow  is false. The optional

                                                                   $ body  argument works like its counterpart in

                                                                   addRow() .
                                                                                                         451




                                                                                                      9/21/09   9:14:50 AM
          c15.indd   451
          c15.indd   451                                                                              9/21/09   9:14:50 AM
   484   485   486   487   488   489   490   491   492   493   494