OK, I'm learning. Maybe you can help. Below is a code chunk I've created to print a hierarchical report. It looks clunky around the table code. Is there a way to tighten the code?😕
$db = mysql_connect( $dbserver, $dbuser, $dbpassword )or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db( $dbname );
$result = mysql_query( "SELECT company_name, project_name, task_name
FROM companies, projects, tasks
WHERE project_status <7
AND task_status =0
AND task_percent_complete <100
AND company_id = project_company
AND project_id = task_project
ORDER BY company_name, project_name" , $db );
$prev_company_name = "";
$prev_project_name = "";
print "<table border='1'>";
while ($row = mysql_fetch_array($result))
{
$new_company_name = "{$row['company_name']}";
if ($prev_company_name == $new_company_name)
{$new_company_name = "";}
else
{$prev_company_name = $new_company_name;}
$new_project_name = "{$row['project_name']}";
if ($prev_project_name == $new_project_name)
{$new_project_name = "";}
else
{$prev_project_name = $new_project_name;}
print "<tr>";
print "<td>";
print "{$new_company_name} ";
print "</td>";
print "<td>";
print "{$new_project_name} ";
print "</td>";
print "<td>";
print "{$row['task_name']}";
print "</td>";
print "</tr>";
}
print "</table>";