Today, I made my first test using html_table. did an example from a book, looked around internet. Am able to make it do some things thus far, columns, bground.
However, one issue that I have given up on for now. No matter how I structure the html_table() line, it does not render any parameters on the <table> line in the html. I wonder if I am encountering something to do with Apache on XP. Here is my code.
Thanks for anyones thoughts.
<?php
// Include the HTML_Table package
require_once 'includes/html/Table.php';
$attrib10 = array('width'=>'100%', 'border'=>'1', 'bordercolor'=>'#9900FF');
$table = new HTML_Table(attrib10);
//$table = new HTML_Table("border=\"1\"");
// Assemble the data in an array
$salesreport = array(
'0' => array("12309","45633","2005-12-19 01:13:42","$22.04","$5.67","$27.71"),
'1' => array("12310","942","2005-12-19 01:1<?php
?>5:12","$11.50","$3.40","$14.90"),
'2' => array("12311","7879","2005-12-19 01:15:22","$95.99","$15.00","$110.99"),
'3' => array("12312","55521","2005-12-19 01:30:45","$10.75","$3.00","$13.75")
);
// Create the table object
$table = new HTML_Table();
$table->setAutoGrow(true);
// Set the headers
$table->setHeaderContents(0, 0, "Order ID");
$table->setHeaderContents(0, 1, "Client ID");
$table->setHeaderContents(0, 2, "Order Time");
$table->setHeaderContents(0, 3, "Sub Total");
$table->setHeaderContents(0, 4, "Shipping Cost");
$table->setHeaderContents(0, 5, "Total Cost");
$hrAttrs = array('bgcolor' => 'silver');
$table->setRowAttributes(0, $hrAttrs, true);
$table->setColAttributes(0, $hrAttrs);
// Cycle through the array to produce the table data
for($rownum = 0; $rownum < count($salesreport); $rownum++) {
for($colnum = 0; $colnum < 6; $colnum++) {
$table->setCellContents($rownum+1, $colnum, $salesreport[$rownum][$colnum]);
}
}
//$table->altRowAttributes(1,null,array("class"=>"alt"));
//alternate row background between 2 colors
$attributes1 = 'bgcolor = #CCFFFF';
$attributes2 = 'bgcolor = #FFFF66';
$table->altRowAttributes(1, $attributes1, $attributes2);
// Output the data
echo $table->toHtml();
?>