- <style>
- TABLE.smtTable{
- border-left:1px black solid;
- border-right:1px solid black;
- border-bottom:1px solid black;
- border-top:1px solid black;
- margin-right:15px;
- width:800px;
- font-size:11pt;
- }
-
- TR.smtRowOdd{
-
- background-color:lightgrey;
- }
- TR.smtRowEven{
- background-color:white;
- }
- TR.smtHeader{
- background-color:#2d1663;
- background-color:#F0F0F0;
- color:#2d1663;
- font-weight:bold;
- font-size:13pt;
- }
- </style>
-
-
-
- <?php
-
-
-
- function DisplayTable($tablehead,$tabledata,$styletable='smtTable',$stylehead='smtHeader')
- {
-
- //Creating HTML table
- $table='<table class=' . $styletable .'>'."\n";
- $table.='<tr class=' . $stylehead . '>' . "\n";
-
- //now displaying table head
- $col=count($tablehead);
-
- //Looping inside tableheaders and displaying them
- foreach ($tablehead as $t)
- {
- if (empty($t)) {$t='_';}$table.='<td>' .$t.'</td>'."\n";
- }
- $table.='</tr>'."\n";
-
-
- //now displaying data with row colors
- $numel=count($tabledata); //amount of cells
- $rows=intval($numel/$col); // line count is cells/col
- $pointeur=0; //pointeur for data
- //first loop, we are going through each row, row length is based on number of Header element
- for ($i=0;$i<$rows;$i++)
- {
- //changing row color. Using modulo function (always returns 1 or 0)
- if ($i%2 == 0) $s="smtRowEven"; else $s="smtRowOdd";
- $table.='<tr class=' . $s . '>' . "\n";
- //We display each cells in the row. Number of Colums is based on number of header as set above
- for ($j=0;$j<$col;$j++)
- {
- $d=$tabledata[$pointeur];
-
- if (empty($d)) {$d='_';}$table.='<td >' . $d . '</td>' . "\n";
- $pointeur++; // moving to next element on tableset
- }
- $table.='</tr>'."\n";
- }
- $table.='</table>'."\n";
- return $table;
- }
-
- $head=array("head1","head2","head3","test1");
- $data=array("r1d1","r1d2","r2d1","r2d2","r3d1","r3d2","r2d2","r3d1","r3d2");
- $d=DisplayTable($head,$data);
- print $d;
- print "done";
-
- ?>
<style>
TABLE.smtTable{
border-left:1px black solid;
border-right:1px solid black;
border-bottom:1px solid black;
border-top:1px solid black;
margin-right:15px;
width:800px;
font-size:11pt;
}
TR.smtRowOdd{
background-color:lightgrey;
}
TR.smtRowEven{
background-color:white;
}
TR.smtHeader{
background-color:#2d1663;
background-color:#F0F0F0;
color:#2d1663;
font-weight:bold;
font-size:13pt;
}
</style>
<?php
function DisplayTable($tablehead,$tabledata,$styletable='smtTable',$stylehead='smtHeader')
{
//Creating HTML table
$table='<table class=' . $styletable .'>'."\n";
$table.='<tr class=' . $stylehead . '>' . "\n";
//now displaying table head
$col=count($tablehead);
//Looping inside tableheaders and displaying them
foreach ($tablehead as $t)
{
if (empty($t)) {$t='_';}$table.='<td>' .$t.'</td>'."\n";
}
$table.='</tr>'."\n";
//now displaying data with row colors
$numel=count($tabledata); //amount of cells
$rows=intval($numel/$col); // line count is cells/col
$pointeur=0; //pointeur for data
//first loop, we are going through each row, row length is based on number of Header element
for ($i=0;$i<$rows;$i++)
{
//changing row color. Using modulo function (always returns 1 or 0)
if ($i%2 == 0) $s="smtRowEven"; else $s="smtRowOdd";
$table.='<tr class=' . $s . '>' . "\n";
//We display each cells in the row. Number of Colums is based on number of header as set above
for ($j=0;$j<$col;$j++)
{
$d=$tabledata[$pointeur];
if (empty($d)) {$d='_';}$table.='<td >' . $d . '</td>' . "\n";
$pointeur++; // moving to next element on tableset
}
$table.='</tr>'."\n";
}
$table.='</table>'."\n";
return $table;
}
$head=array("head1","head2","head3","test1");
$data=array("r1d1","r1d2","r2d1","r2d2","r3d1","r3d2","r2d2","r3d1","r3d2");
$d=DisplayTable($head,$data);
print $d;
print "done";
?>