PHP Classes

File: 04_custom_function_tr_id.php

Recommend this page to a friend!
  Classes of Alexandre Sinício   PHP Array into HTML Table   04_custom_function_tr_id.php   Download  
File: 04_custom_function_tr_id.php
Role: Example script
Content type: text/plain
Description: Example - Defining ID for 'tr' tags
Class: PHP Array into HTML Table
Generate HTML tables from data in arrays
Author: By
Last change:
Date: 7 years ago
Size: 637 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")
    );
   
   
$trIDFunction = function($row) {
        if (
$row[1] == "come") {
            return
"blue";
        } else {
            return
null;
        }
    };
   
   
$table = new HTMLTable();
   
$table->setData($arrData);
   
$table->setHeaders($arrHeaders);
   
$table->setTrIDFunction($trIDFunction);
    echo
$table->getHTML();
   
    echo
"<style>
        #blue{background-color: blue;}
        </style>"
;