File: 02_defining_classes.php

Recommend this page to a friend!
  Classes of Alexandre Sinício  >  PHP Array into HTML Table  >  02_defining_classes.php  >  Download  
File: 02_defining_classes.php
Role: Example script
Content type: text/plain
Description: Example - Defining classes to elements
Class: PHP Array into HTML Table
Generate HTML tables from data in arrays
Author: By
Last change:
Date: 5 years ago
Size: 672 bytes
 

Contents

Class file image Download
<?php
   
use alesinicio\HTMLTable;

    require
"../HTMLTable.php";
   
   
$arrHeaders = array(
       
"First column", "Second column", "Third column", "Fourth column"
   
);
   
   
$arrData = array(
        array(
"this", "is", "first", "row"),
        array(
"could", "come", "from", "database")
    );
   
   
$arrTDClasses = array("red", "blue", "green", "grey");
   
   
$table = new HTMLTable();
   
$table->setData($arrData);
   
$table->setHeaders($arrHeaders);
   
$table->setTdClasses($arrTDClasses);
    echo
$table->getHTML();
   
    echo
"<style>
        .red{background-color: red;}
        .green{background-color: green;}
        .blue{background-color: blue;}
        .grey{background-color: grey;}
        </style>"
;

For more information send a message to info at phpclasses dot org.