一个table的类
class TABLE {

    var $TABLE_NAME = '';

    var $ALIGN = 'LEFT';
    var $VALIGN ="TOP";
    var $BORDER = 1;
    var $WIDTH = '100%';
    var $BGCOLOR = '#FFFFFF';
    var $BORDERCOLOR = '#000000';
    var $CELLSPACING = 1;
    var $CELLPADDING = 1;
    var $BGIMAGE = '';
    
    var $NOWRAP = 0;
    var $COLSPAN = 0;
    var $ROWSPAN = 0;
    var $BGCOLOR = '#FFFFFF';
    
    var $FONT_FACE = 'Arial';
    var $FONT_SIZE = '2';
    var $FONT_COLOR = '#000000';
    
    
    function set($var, $value) {
        $var = strtoupper($var);
        $this->$var = $value;
    }
    
    function start($t_name) {
        $this->TABLE_NAME = $t_name;
        $t_str =  "nn<!------------------- TABLE BEGINS: $t_name -------------------->nn";
        $t_str .= "<DIV ALIGN='" . $this->ALIGN . "'><TABLE BORDER='" . $this->BORDER . "' BORDERCOLOR='" . $this->BORDERCOLOR . "' WIDTH='" . $this->WIDTH . "' BGCOLOR='" . $this->BGCOLOR . "' CELLSPACING='" . $this->CELLSPACING . "' CELLPADDING='" . $this->CELLPADDING . "' BACKGROUND='" . $this->BGIMAGE . "'>n";
        return $t_str;
    }
    
    function tr($var) {
        $t_str = "<TR>n";
        $t_str .= $var;
        $t_str .= "</TR>n";
        
        return $t_str;
    }

    function td($var) {
        
        $t_str = '';

        if($this->ROWSPAN != 0){
            $r_str = " ROWSPAN='" . $this->ROWSPAN . "' ";
        }
        if($this->COLSPAN !=0) {
            $c_str = " COLSPAN='" . $this->COLSPAN . "' ";
        }
        if($this->WIDTH !=0) {
            $w_str = " WIDTH='" . $this->WIDTH . "' ";
        }    
        $cr_str = $c_str . $r_str;

        if($this->NOWRAP) {
            $nowrap = ' NOWRAP ';
        }
        $t_str .= "<TD BGCOLOR='" . $this->BGCOLOR . "' ALIGN='" . $this->ALIGN . "' VALIGN='" .$this->VALIGN . "'" .  $w_str . $cr_str . $nowrap . ">n";
        $t_str .= "<FONT FACE='" . $this->FONT_FACE . "' SIZE='" . $this->FONT_SIZE . "' COLOR='" . $this->FONT_COLOR . "'>". $var . "</FONT>";
        $t_str .= "</TD>n";

        return $t_str;
    }    

    function th($var) {
        
        $t_str = '';

        if($this->ROWSPAN != 0){
            $r_str = " ROWSPAN='" . $this->ROWSPAN . "' ";
        }
        if($this->COLSPAN !=0) {
            $c_str = " COLSPAN='" . $this->COLSPAN . "' ";
        }
        if($this->WIDTH !=0) {
            $w_str = " WIDTH='" . $this->WIDTH . "' ";
        }    
            
        $cr_str = $c_str . $r_str;

        if($this->NOWRAP) {
            $nowrap = 'NOWRAP';
        }
        $t_str .= "<TH BGCOLOR='" . $this->BGCOLOR . "' ALIGN='" . $this->ALIGN . "' VALIGN='" .$this->VALIGN . "'" . $w_str . $cr_str . $nowrap . ">n";
        $t_str .= "<FONT FACE='" . $this->FONT_FACE . "' SIZE='" . $this->FONT_SIZE . "' COLOR='" . $this->FONT_COLOR . "'>". $var . "</FONT>";
        $t_str .= "</TH>n";
        return $t_str;
    }    
    
    function end() {
        $t_str = "</TABLE></DIV>n";
        $t_str .= "nn<!------------------- TABLE ENDS: " . $this->TABLE_NAME . " -------------------->nn";
        $TABLE_NAME = '';
    
        $this->ALIGN = 'LEFT';
        $this->VALIGN ="TOP";
        $this->BORDER = 1;
        $this->WIDTH = '100%';
        $this->BGCOLOR = '#FFFFFF';
        $this->BORDERCOLOR = '#000000';
        $this->CELLSPACING = 1;
        $this->CELLPADDING = 1;
        $this->BGIMAGE = '';
        
        $this->HEADER = 0;
        $this->NOWRAP = 0;
        $this->COLSPAN = 0;
        $this->ROWSPAN = 0;
        $this->BGCOLOR = '#FFFFFF';
        
        $this->FONT_FACE = 'Arial';
        $this->FONT_SIZE = '2';
        $this->FONT_COLOR = '#000000';

        return $t_str;
    }
    
}
?>