Location: PHPKode > scripts > Table Maker > table-maker/TableMakerClass.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title>Table Maker Documentation</title>
	<style type="text/css">
	.term  {
     	vertical-align : top;
     	font-weight : bold;
     }
     
     .retval  {
     	font-style : italic;
     }
     
     </style>
</head>

<body>
<h1>Table Maker Class</h1>

	Class TableMaker by Karsten J. Mikkelsen (hide@address.com)<br>
	Version 1.0, June 2002<br>
	A class for easy creation of HTML tables<br>

<h2>Constructor</h2>
<span class="term">TableMaker([$tableAttributes])</span>
<table>
	<tr>
		<td class="term">$tableAttributes</td>
		<td>
			An associative array of attributes for the table tag. 
			No syntax checking is involved, so the attributes must be valid in order to work and will be ignored otherwise.
			The parameter is optional. The table will have no attributes if $tableAttributes is not supplied.
			<br>
			E.g. array("Border" => 0, "Cellspacing" => 0).
		</td>
	</tr>
</table>

<h2>Methods</h2>

<span class="term">defineCaption(<span class="retval">String</span> $captionString, <span class="retval">Array</span> $captionAttributes)</span>
<p>Define the attributes for a table caption. Only one caption can be defined. Attributes are added or overwritten. Previously defined attributes remain unchanged..<br>
<span class="term">$captionString: </span>The caption text.<br>
<span class="term">$captionAttributes: </span>An array of attributes for the &lt;caption&gt; tag, corresponding to $tableAttributes in the constructor.
</p>

<span class="term">addCaption (<span class="retval">String</span> $captionString [, <span class="retval">Array</span> $captionAttributes])</span>
<p>Add a table row (&lt;tr&gt;&lt;/tr&gt; tags).<br>
<span class="term">$captionString: </span>The text to be displayed as a caption.<br>
<span class="term">$captionAttributes: </span>An array of attributes for the &lt;caption&gt; tag, corresponding to $tableAttributes in the constructor.
</p>

<span class="term">defineRow(<span class="retval">String</span> $rowID, <span class="retval">Array</span> $rowAttributes)</span>
<p>Define the attributes for a table row type. Only works on subsequently added rows. Attributes are added or overwritten. Previously defined attributes remain unchanged if not included.<br>
<span class="term">$rowID: </span>A unique identifier of this row type. Use 'default' to set default attributes.<br>
<span class="term">$rowAttributes: </span>An array of attributes for the &lt;tr&gt; tag, corresponding to $tableAttributes in the constructor.
</p>

<span class="term">addRow [(<span class="retval">String</span> $rowID] [, <span class="retval">Array</span> $rowAttributes])</span>
<p>Add a table row (&lt;tr&gt;&lt;/tr&gt; tags).<br>
<span class="term">$rowID: </span>A unique identifier of this row type. A row of type $rowID is inserted. Use 'default' or omit parameters to insert a row with default attributes.<br>
<span class="term">$rowAttributes: </span>An array of attributes for the &lt;tr&gt; tag, corresponding to $tableAttributes in the constructor.
</p>

<span class="term">defineHeader (<span class="retval">String</span> $headerID, <span class="retval">Array</span> $headerAttributes)</span>
<p>Define the attributes for a table header type. Only works on subsequently added &lt;th&gt; tags. Attributes are added or overwritten. Previously defined attributes remain unchanged if not included.<br>
<span class="term">$headerID: </span>A unique identifier of this header type. Use 'default' to set default attributes.<br>
<span class="term">$headerAttributes: </span>An array of attributes for the &lt;th&gt; tag, corresponding to $tableAttributes in the constructor.
</p>

<span class="term">addHeader ([<span class="retval">String</span> $headerData] [, <span class="retval">String</span> $headerID] [<span class="retval">, Array</span> $headerAttributes])</span>
<p>Add a table header cell (&lt;th&gt;&lt;/th&gt; tags) with contents.<br>
<span class="term">$headerData: </span>The text that constitutes the header. If omitted, a space character (&amp;nbsp;) is used.<br>
<span class="term">$headerID: </span>A unique identifier of this header type. A data cell of type $headerID is inserted. Use 'default' or omit parameters to insert a header with default attributes.<br>
<span class="term">$headerlAttributes: </span>An array of attributes for the &lt;th&gt; tag, corresponding to $tableAttributes in the constructor.
</p>

<span class="term">defineDataCell (<span class="retval">String</span> $cellID, <span class="retval">Array</span> $cellAttributes)</span>
<p>Define the attributes for a data cell type. Only works on subsequently added &lt;td&gt; tags. Attributes are added or overwritten. Previously defined attributes remain unchanged if not included.<br>
<span class="term">$cellID: </span>A unique identifier of this data cell type. Use 'default' to set default attributes.<br>
<span class="term">$cellAttributes: </span>An array of attributes for the &lt;td&gt; tag, corresponding to $tableAttributes in the constructor.
</p>

<span class="term">addData ([<span class="retval">String</span> $cellData] [, <span class="retval">String</span> $cellID] [<span class="retval">, Array</span> $cellAttributes])</span>
<p>Add a data cell (&lt;td&gt;&lt;/td&gt; tags) with contents.<br>
<span class="term">$cellData: </span>The data to be contained in this data cell. If omitted, a space character (&amp;nbsp;) is used.<br>
<span class="term">$cellID: </span>A unique identifier of this data cell type. A data cell of type $cellID is inserted. Use 'default' or omit parameters to insert a cell with default attributes.<br>
<span class="term">$cellAttributes: </span>An array of attributes for the &lt;td&gt; tag, corresponding to $tableAttributes in the constructor.
</p>

<span class="term"><span class="retval">String</span> getTable()</span>
<p>Return the table as a string</p>

<span class="term">writeTable()</span>
<p>Write the table into the current document</p>

<span class="term">setIndentation(<span class="retval">String</span> $indentString, <span class="retval">Integer</span> $tblIndent, <span class="retval">Integer</span> $trIndent, <span class="retval">Integer</span> $tdIndent, <span class="retval">Integer</span> $dataIndent)</span>
<p>Define the indentation string and levels for the HTML code.<br>
<span class="term">$indentString: </span>The string to be used for indentation. The default is one tab charachter (&quot;\t&quot;).<br>
<span class="term">$tblIndent, $trIndent, $tdIndent, $dataIndent: </span>The indentation levels for &lt;table&gt;, &lt;tr&gt;, &lt;td&gt; tags and table cell contents, respectively. Use non-negative values.<br>
The default would be defined like this: setIndentation(&quot;\t&quot;, 1, 2, 3, 4);<br>
</p>

<span class="term">setCase(<span class="retval">String</span> $newCase)</span><br>
<p>Change tag case to uppercase, lowercase or uppercase first letter</p>
<ul>
	<li>u or upper = uppercase (the default)</li>
	<li>l or lower = lowercase</li>
	<li>f or first = uppercase first letter</li>
</ul>
</body>
</html>
Return current item: Table Maker