Example using PHP Table Class

Back to Table Class

Example table created using the PHP table class:

Product Single Item Price Price per Dozen
Chocolate Chip Cookies $1.25 $10.00
Oatmeal Cookies $0.99 $8.25
Fudge Brownies $1.35 $12.00

Source code used to generate above table:

<?php
require($_SERVER['DOCUMENT_ROOT'] . 'includes/html_table.class.php');

$PRODUCTS = array(
    
'choc_chip' => array(' Chocolate Chip Cookies'1.2510.00),
    
'oatmeal' => array('Oatmeal Cookies'.998.25),
    
'brwwnies' => array('Fudge Brownies'1.3512.00)
);

$tbl = new HTML_Table(null'display'104);

$tbl->addRow();
    
$tbl->addCell('Product''first''header');
    
$tbl->addCell('Single Item Price'null'header');
    
$tbl->addCell('Price per Dozen'null'header');
    
    foreach(
$PRODUCTS as $product) {
        list(
$name$unit_price$doz_price ) = $product;
        
$tbl->addRow();
            
$tbl->addCell($name);
            
$tbl->addCell('$' number_format($unit_price2), 'num' );
            
$tbl->addCell('$' number_format($doz_price2), 'num' );
    }
echo 
$tbl->display();
?>

Back to Table Class | top