Login   Register  
PHP Classes
elePHPant
Icontem

File: sample.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Junrey Beduya  >  Table Class  >  sample.php  >  Download  
File: sample.php
Role: ???
Content type: text/plain
Description: An php file utilizing the Table Class
Class: Table Class
Author: By
Last change:
Date: 2002-04-16 02:10
Size: 2,858 bytes
 

Contents

Class file image Download
<html>
<head>
<title>Table Class Sample</title>
<style type="text/css">
TR.level1 { 
	background-color  : #354463; 
	font-family: Arial; 
	font-size: 11px; 
	color: white; 
	padding-left: 5px; 
}
TR.level2 { 
	background-color  : #5F7797; 
	font-family: Arial; 
	font-size: 11px; 
	color: white; 
	padding-left: 5px; 
}
</style>
</head>
<body>
<?
	// include the class
	require("class.Table.php");
	
	echo "<H2>First Example</H2>";
	// create a table with four columns
	$table = new Table(4); 
	
	// column headers are separated by (^) caret
	$table->setHeaders("No.^Product Code^Descripttion^Amount");
	
	// you can set some property here as backgroundcolor or whatsoever
	// property of the row
	$table->setHeaderProperty("class=level1");
	
	// set the column width
	// the default column width is pixel not percent
	$table->setColWidth("20,100,300,100");
	
	// set the table spacing
	$table->setSpacing(1);
	// this property is used to set the alignment of the columns
	// not including the header
	// NOTE:
	//		The default alignment of the header is CENTERed and BOLD
	// 	You can set its alignment through setHeaderStyle($start, $end)
	//			start and end parameter stands for start and end tag
	//		EX: setHeaderStyle("<center>", "</center>")
	$table->setColAlignment("center,,,right");
	
	// let us say we have this array
	$name[0]["code"] = "V2399";
	$name[0]["desc"] = "Sony VHS";
	$name[0]["amount"] = "P 5,000.00";
	$name[1]["code"] = "V2380";
	$name[1]["desc"] = "Samsung VHS";
	$name[1]["amount"] = "P 6,906.00";
	$name[2]["code"] = "V2378";
	$name[2]["desc"] = "LG Electric Fan";
	$name[2]["amount"] = "P 2,454.00";
	
	for ($i=0; $i<=2; $i++) {
		// table entry are also separated by caret(^) also
		// the second option is for the row property
		$table->AddRow(($i+1)."^".$name[$i]["code"]."^".$name[$i]["desc"]."^".$name[$i]["amount"],"class=level2");		
	}
	$table->Process();
	$table->Display();
	
//=========================================================================
// this is second table example wherein we set this as percent
// we must have to change the setColWidth function to make it 100 percent
//=========================================================================
	echo "<H2>Second Example</H2>";
	$table = new Table(4); 
	$table->setHeaders("No.^Product Code^Descripttion^Amount");
	$table->setHeaderProperty("class=level1");

	// this is the property that we change
	$table->setColWidth("10,25,40,25");
	// the property that we added
	$table->setPercent();
	$table->setSpacing(1);
	$table->setColAlignment("center,,,right");
	for ($i=0; $i<=2; $i++) {
		$table->AddRow(($i+1)."^".$name[$i]["code"]."^".$name[$i]["desc"]."^".$name[$i]["amount"],"class=level2");		
	}
	$table->Process();
	$table->Display();
?>
</body>
</html>