$value, attributes=>$attributes) var $row_index; // index of current row var $column_count; // number of columns var $column_counter; // number of columns function HTMLTable($table_attributes = "", $table_body_attributes = "") { $this->table_attributes = $this->prepend_space($table_attributes); $this->table_body_attributes = $this->prepend_space($table_body_attributes); // initialize other properties $this->table_header = ""; $this->table_header_attributes = ""; $this->table_footer = ""; $this->table_footer_attributes = ""; $this->column_headers = array(); $this->row_attributes = array(); $this->rows = array(); $this->row_index = 0; $this->column_count = 0; $this->column_counter = 0; } function add_header($value, $attributes = "") { $this->table_header = $value; $this->table_header_attributes = $this->prepend_space($attributes); } function add_footer($value, $attributes = "") { $this->table_footer = $value; $this->table_footer_attributes = $this->prepend_space($attributes); } function add_column_header($value, $attributes = "") { $this->column_headers[] = array("value" => $value, "attributes" => $this->prepend_space($attributes)); } function begin_row ($attributes = "") { if ($this->column_counter > $this->column_count) { $this->column_count = $this->column_counter; } $this->column_counter = 0; $this->row_index++; $this->row_attributes[$this->row_index] = $this->prepend_space($attributes); } function add_cell($value, $attributes="") { $this->rows[$this->row_index][] = array("value" => $value, "attributes" => $this->prepend_space($attributes)); $this->column_counter++; } function prepend_space($value) { if ($value != "") { return " " . $value; } else { return ""; } } function debug() { print "
";
		print_r($this->rows);
		print "
"; } function generate() { print "\ntable_attributes . ">\n"; // only print "THEAD" if there is a table header and/or column headers if ($this->table_header != "" || $this->column_count != 0) { print "table_header_attributes . ">\n"; // print header row that spans the entire table if one is provided if ($this->table_header != "") { print "\n"; print "\t"; print $this->table_header; print "\n"; print "\n"; } // print column headers if provided if (count($this->column_headers) != 0) { print "table_head_attributes . ">\n"; foreach ($this->column_headers as $th) { print "\t"; print $th["value"]; print "\n"; } print "\n"; } print "\n"; } //print table footer if ($this->table_footer != "") { print "table_footer_attributes . ">\n"; print "\n"; print "\t"; print $this->table_footer; print "\n"; print "\n"; print "\n"; } // print table body if (count($this->rows) != 0) { print "table_body_attributes . ">\n"; foreach ($this->rows as $row_index => $row) { print "row_attributes[$tr_index] . ">\n"; foreach ($row as $cell) { print "\t"; print $cell["value"]; print "\n"; } print "\n"; } print "\n"; } print "\n"; } } ?>