PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Outdated profile   tablebuilder   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Simple example well commented
Class: tablebuilder
Class for easy composing complex html tables
Author: By
Last change:
Date: 21 years ago
Size: 1,389 bytes
 

Contents

Class file image Download
<?

   
include "table.inc.php";
   
   
// Create a table
    // Parameters are: <width>, <style name for table>, <cellpadding>, <cellspacing>
   
$table = new table ("100%", "", "", "");
   
   
// Adding the first row to our table
    // The parameters for each row are: <array of table_cell>, <style name for tr>
    // The parameters for each cell are: <content of the cell>, <colspan>, <style name for td>, <string to highlight inside this cell>, <wether or not to avoid carriage returns (true|false)>
   
$table->addrow
   
(
        new
table_row
       
(
            array
            (
                new
table_cell ("column 1", "", "table_header", "", true),
                new
table_cell ("column 2", "", "table_header", "", true),
                new
table_cell ("column 3", "", "table_header", "", true),
                new
table_cell ("column 4", "", "table_header", "", true),
                new
table_cell ("column 5", "", "table_header", "", true)
            ),
           
""
       
)
    );

   
// A simple loop for adding 10 more rows to the table
   
for ($i=0; $i<10; $i++)
       
$table->addrow
       
(
            new
table_row
           
(
                array
                (
                    new
table_cell ("value 1", "", "", "", true),
                    new
table_cell ("value 2", "", "", "", true),
                    new
table_cell ("value 3", "", "", "", true),
                    new
table_cell ("value 4", "", "", "", true),
                    new
table_cell ("value 5", "", "", "", true)
                ),
               
""
           
)
        );
       
   
// Showing our table
   
echo $table->get ();

?>