tag. var $col_style = array(); // default style for table column. enclosed in tags. var $col_cell_style = array(); // default style for column cells. enclosed in tags. var $cell_style = ''; // default cell style. enclosed in tags. var $table_style = ''; // default table style. enclosed in tags. function cell_init() { return array( 'content' => $this->cell_content, 'style' => '', 'cell_style'=> ''); } function init($parameters) { if (isset($parameters['cols'])) $this->cols = $parameters['cols']; if (isset($parameters['rows']))$this->rows = $parameters['rows']; for ($row = 1; $row <= $this->rows; $row++) { for ($col = 1; $col <= $this->cols; $col++) { $this->cell[$row][$col] = $this->cell_init(); } } } function add_rows($num_rows) { for ($row = 1; $row <= $num_rows; $row++) { for ($col = 1; $col <= $this->cols; $col++) { $this->cell[$row + $this->rows][$col] = $this->cell_init(); } } $this->rows += $num_rows; } function add_cols($num_cols) { for ($row = 1; $row <= $this->rows; $row++) { for ($col = 1; $col <= $num_cols; $col++) { $this->cell[$row][$col+$this->cols] = $this->cell_init(); } } $this->cols += $num_cols; } function code() { if (!empty($this->html)) return 1; $this->html = '
table_style.'>'."\n"; for ($row = 1; $row <= $this->rows; $row++) { $this->html .= ' '."\n"; for ($col = 1; $col <= $this->cols; $col++) { $extra = ''; //check if "colspan" defined. if so then hide cells that get merged. if (isset($this->cell[$row][$col]['colspan'])) { $extra .= 'COLSPAN="'.$this->cell[$row][$col]['colspan'].'"'; for ($hidden_col = 1; $hidden_col < $this->cell[$row][$col]['colspan']; $hidden_col++) { $this->cell[$row][$col+$hidden_col]["hide"] = true; //check if "rowspan" defined. if so then propogate "colspan" into merged rows. if (isset($this->cell[$row][$col]["rowspan"])) { for ($hidden_row = 1; $hidden_row < $this->cell[$row][$col]['rowspan']; $hidden_row++) { $this->cell[$row+$hidden_row][$col]["colspan"] = $this->cell[$row][$col]['colspan']; } } } } //check if "rowspan" defined. if so then hide cells that get merged. if (isset($this->cell[$row][$col]["rowspan"])) { $extra .= 'ROWSPAN="'.$this->cell[$row][$col]['rowspan'].'"'; for ($hidden_row = 1; $hidden_row < $this->cell[$row][$col]['rowspan']; $hidden_row++) { $this->cell[$row+$hidden_row][$col]["hide"] = true; } } // code to draw cell html... if (isset($this->cell[$row][$col]['hide'])) continue; // if hide then skip this cell. // otherwise draw cell with style... if (!empty($this->cell[$row][$col]['cell_style'])) $this->html .= ' '."\n"; } $this->html .= ' '."\n"; } $this->html .= '
cell[$row][$col]['cell_style'].' '.$extra.'>'; else if (!empty($this->col_style[$col])) $this->html .= ' col_style[$col].' '.$extra.'>'; else $this->html .= ' cell_style.' '.$extra.'>'; // draw content of cell with style... if (!empty($this->cell[$row][$col]['style'])) $this->html .= 'cell[$row][$col]['style'].'>'; else if (!empty($this->col_cell_style[$col])) $this->html .= 'col_cell_style[$col].'>'; else if (!empty($this->content_style)) $this->html .= 'content_style.'>'; $this->html .= $this->cell[$row][$col]['content']; if (!empty($this->cell[$row][$col]['style']) or !empty($this->col_cell_style[$col]) or !empty($this->content_style)) $this->html .= ''; $this->html .= '
'."\n"; } function display() { if (empty($this->html)) $this->code(); print $this->html; } } // end of class html_table.