$rowNum = 0;
print "
";
print formatTableHeader($headers,$columns);
foreach($result as $l)
{
if (is_section_header($l,$columns))
{
print formatSectionHeader($l,$columns);
}
else
{
if (($rowNum % 2) == 0)
{
print formatTableRow($l,"lightg");
}
else
print formatTableRow($l);
}
$rowNum++;
}
print "
";
//var_dump($result);
function formatTableHeader($cols)
{
$retval = "\n";
foreach ($cols as $c)
{
$retval .= "$c | ";
}
$retval .= "
\n";
return $retval;
}
function is_section_header($arr,$cols)
{
$retval = false;
for($i=1;$i<$cols;$i++)
{
if (trim($arr[$i]) !== '')
return false;
}
return true;
}
function formatSectionHeader($hdr,$cols)
{
$hdr = trim(implode($hdr));
$retval = "\n";
$retval .= "$hdr | \n";
$retval .= "
\n";
return $retval;
}
function formatTableRow($row,$class=null)
{
if ($class != null)
$c = "class=\"$class\"";
else
$c = "";
$retval = "\n";
foreach ($row as $f)
{
if (strtolower(trim($f)) === "yes")
$c = "class=\"yestxt\"";
else if (strtolower(trim($f)) === "no")
$c = "class=\"notxt\"";
else
$c = "";
$retval .= "$f | \n";
}
$retval .= "
\n";
return $retval;
}
?>