PHP Classes

File: table.class.php

Recommend this page to a friend!
  Classes of Ronald van den Berg   Table Class Pro   table.class.php   Download  
File: table.class.php
Role: ???
Content type: text/plain
Description: The main class
Class: Table Class Pro
Author: By
Last change:
Date: 23 years ago
Size: 2,409 bytes
 

Contents

Class file image Download
<? class make_table { var $border = "1"; var $width = "500"; var $class = "tabledefault"; var $tabledata = Array(); var $rows = 0; var $firstrowstyle = "tablehead"; var $cellpadding = "2"; var $cellspacing = "0"; var $bordercolor = "#666666"; // $this-> function set_value($key, $val) { $this->$key = $val; } function output_table () { //echo $this->rows; $buffer = "\n<TABLE BORDER=\"$this->border\" WIDTH=\"$this->width\" BORDERCOLOR=\"$this->bordercolor\""; $buffer .= " CLASS=\"$this->class\" CELLPADDING=\"$this->cellpadding\" CELLSPACING=\"$this->cellspacing\">\n"; for ($i = 1; $i <= $this->rows; $i++) { $rowdata = $this->tabledata[$i]; IF (is_array($rowdata)) { IF ($i == 1 && $this->firstrowstyle) { $buffer .= " <TR class=\"$this->firstrowstyle\"> \n"; } ELSE { $buffer .= " <TR>\n"; } while (list($key, $val) = each($rowdata)) { $buffer .= " <TD"; $buffer .= ($val[colspan]) ? " COLSPAN=\"$val[colspan]\"" : ""; $buffer .= ($val[width]) ? " WIDTH=\"$val[width]\">" : ">"; $buffer .= ($val['val']) ? $val['val'] : "&nbsp;"; $buffer .= "</TD>\n"; } $buffer .= " </TR>\n"; } } $buffer .= "</TABLE>\n"; return $buffer; } function add_row($style = false) { // style isn't used for now $this->rows++; //echo $this->rows; } function add_cell($val = false, $colspan = false, $width = false) { //1st value is the content of the cell //2nd value is the colspan, if empty then there's no colspan //3rd value is the width of the cell $this->tabledata[$this->rows][] = Array ( "val" => $val, "colspan" => $colspan, "width" => $width); } } /* //Example: $table = new make_table; $table->add_row(); $table->add_cell("",'',20); $table->add_cell("Property",'',20); $table->add_cell("Value"); $table->add_row(); $table->add_cell("Name:",'',20); $table->add_cell("Ronald",2); $table->add_row(); $table->add_cell("Address:",2); $table->add_cell("BvdP 304"); $table->set_value("border", 1); $table->output_table(); */ ?>