Location: PHPKode > scripts > Class Table > class-table-1-0/demo.class.table.php
<?php
	require "table.php";
	
	
	/*	
		///////////////////////////////////////////////
		//
		//
		//	T E S T     C O D E
		//
		//
	*/	
	$table = new cls_table;
	
	//	content of table should look like this
	//	
	//		1	2	3	4
	//		2	3	4	5
	//		3	4	5	6
	//		4	5	6	7
	//		5	6	7	8
	//		6	7	8	9

	// table consist of 4 columns and 7 rows
	$table->initialize(4, 7);
	
	$table->set_border(false);
	$table->set_width(350);
	$table->set_color('000000');
  
  for ($int_y = 0; $int_y < 7; $int_y++)
    for ($int_x = 0; $int_x < 4; $int_x++)
      $table->cell[$int_x][$int_y]->set_color('dddddd');

  $table->set_cellspacing(1);

	$table->set_column_width(2, 100);
	$table->set_column_color(2, 'ffffff');
	$table->set_column_align(2, 'center');
	$table->set_column_align(3, 'right');

	$table->set_row_color(0, 'bbbbbb');
	$table->set_row_bold(0, true);
	$table->set_row_italic(0, true);
	$table->set_row_align(0, 'left');
	$table->set_row_valign(0, 'bottom');

	$table->cell[2][0]->set_align('center');
	$table->cell[2][0]->set_valign('center');
	$table->cell[1][1]->set_underline(true);
	$table->cell[1][1]->set_color('ff0000');

	$table->cell[2][3]->set_color('ff0000');

	$table->cell[2][6]->set_color('e0e0ff');
	$table->cell[2][6]->set_bold(true);
	$table->cell[3][6]->set_color('e0e0ff');
	$table->cell[3][6]->set_bold(true);
  
  $table->font->set_color('0000bb');
  $table->cell[1][3]->font->set_color('000000');
  $table->cell[1][3]->font->set_bold(true);
  $table->cell[2][3]->font->set_color('ffffff');
		
	$values = array('Column 1 in a to small cell', 'Column 2', 'Column 3', 'Column 4', 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 5, 6, 7, 8, 6, 7, 8, 9);
	$table->set_values($values);
	
	print $table->build(); 

  
  print "<br><br>";
  
	//	content of table should look like this
	//	
	//		1	2	3	4
	//		2	3	4	5
	//		3	4	5	6
	//		4	5	6	7
	//		5	6	7	8
	//		6	7	8	9
	//		7 8 9 0
	//		8 9 0 1
	//		9 0 1 2

	$values = array('Column 1', 'Column 2', 'Column 3', 'Column 4', '1', '2', '3', '4', '2', '3', '4', '5', '3', '4', '5', '6', '4', '5', '6', '7', '5', '6', '7', '8', '6', '7', '8', '9', '7', '8', '9', '0', '8', '9', '0', '1', '9', '0', '1', '2');


	$table_1 = new cls_table;

	// table consist of 4 columns and 10 rows
	$table_1->initialize(4, 10);
	
	$table_1->set_border(false);
	$table_1->set_width(400);
	$table_1->set_color('000000');
  
  for ($int_y = 0; $int_y < 10; $int_y++)
    for ($int_x = 0; $int_x < 4; $int_x++)
      $table_1->cell[$int_x][$int_y]->set_color('f0f0f0');

	$table_1->set_row_bold(0, true);
  $table_1->set_row_color(0, 'cccccc');
  $table_1->set_column_width(0, 200);

	$table_1->set_values($values);
  
  $table_1->set_value(2, 2, '0');
	
	print $table_1->build(); 


  print "<br>";

	//	content of table should look like this
	//	
	//		1	2	3	4
	//		2	3	4	5
	//		3	4	5	6
	//		4	5	6	7
	//		5	6	7	8
	//		6	7	8	9
	//		7 8 9 0
	//		8 9 0 1
	//		9 0 1 2

  
  for ($int_y = 0; $int_y < 10; $int_y++)
    for ($int_x = 0; $int_x < 4; $int_x++)
      $table_1->cell[$int_x][$int_y]->set_color('f4f4ff');

  $table_1->set_column_color(3, 'ebebff');
  $table_1->set_row_color(0, 'ccccff');
  $table_1->set_cellspacing(1);
  $table_1->set_column_width(1, 150);
	
	print $table_1->build();
?>
Return current item: Class Table