Example #1
0
 public function __construct($rows, $columns, $dom)
 {
     //set the root document
     self::$dom = $dom;
     //create the table and add it to the dom
     $this->table = self::$dom->createElement('table');
     $this->table->setAttribute('id', 'table');
     self::$dom->appendChild($this->table);
     //initialize num_rows/num_columns
     $this->num_rows = $rows;
     $this->num_columns = $columns;
     //create all the cells in the table
     for ($i = 0; $i < $rows; $i++) {
         $row = self::$dom->createElement('tr');
         for ($j = 0; $j < $columns; $j++) {
             $cell = self::$dom->createElement('td');
             $cell->setAttribute('id', 'row' . $i . 'cell' . $j);
             $row->appendChild($cell);
         }
         $row->setAttribute('id', 'row' . $i);
         //append the row to the table
         $dom->searchForElementById('table')->appendChild($row);
     }
     return $this;
 }