It's not bad, but I see a few ways to improve this. The first problem I see here is the way you duplicate your variables. Example:
$row = mysql_fetch_array($result);
//Get ID values
if($row) {
$CoID = $row["CompanyID"];
$id = $row["ProfileID"];
}
It's enough just to say:
$row = mysql_fetch_row($result);
// Sipmly do: echo $row['CompanyID']; to return the value.
// You don't need the IF because if no results are found there'll be no $row['CompanyID'] and if there's a SQL error your script will halt.
The biggest way to improve this script is to cut the redundancy. For example:
Slight variations of this snippet appear 6 times throughout your code
$tableinfo .= "<tr bgcolor=$color>
<td nowrap>$EEid</td>
<td nowrap>$last, $first</td>
<td nowrap>$city, $state</td>
<td nowrap>$hplan<br>$htype</td>
<td nowrap>$dplan<br>$dtype</td>
<td nowrap class=\"small\"><A HREF=\"employee_forms.php?id=$EEid\">Forms</A></td>
<td nowrap>
<A HREF=\"employees_edit.php?id=$EEid\"><IMG SRC=\"/admin/images/b-edit.gif\" BORDER=\"0\"
ALT=\"Edit Employee Profile\"></A></td>
<td nowrap class=\"small\">
<A HREF=\"employees_del.php?id=$EEid\"><IMG SRC=\"/admin/images/b-delete.gif\" BORDER=\"0\"
ALT=\"Delete Employee and Spouse Profiles\"></A>
</td>
<td nowrap class=\"small\"><A HREF=\"spouse_edit.php?id=$EEid\">Edit</A></td>
<td class=\"small\">n/a</td>
</tr>\n";
This is the perfect time to use a function:
// This is loosely written, you'll need to work through creating your own.
function tableInfo($color, $EEid, $last, $city, $hplan, $dplan, $status)
{
$tableinfo .= "<tr bgcolor=$color>
<td nowrap>$EEid</td>
<td nowrap>$last, $first</td>
<td nowrap>$city, $state</td>
<td nowrap>$hplan<br>$htype</td>
<td nowrap>$dplan<br>$dtype</td>
<td nowrap class=\"small\"><A HREF=\"employee_forms.php?id=$EEid\">Forms</A></td>
<td nowrap>
<A HREF=\"employees_edit.php?id=$EEid\"><IMG SRC=\"/admin/images/b-edit.gif\" BORDER=\"0\"
ALT=\"Edit Employee Profile\"></A></td>
<td nowrap class=\"small\">
if ($status == "x")
{
echo "some html";
}
else
{
echo "alternative html";
}
<td nowrap class=\"small\"><A HREF=\"spouse_edit.php?id=$EEid\">Edit</A></td>
<td class=\"small\">n/a</td>
</tr>\n";
}
// Show table
tableInfo($varsX..);
// Show another table
tableInfo($varsY...);
One other minor point. Your HTML should be more standard. Example:
<table bgcolor=$color> should be <table bgcolor="$color">
This is not really that big of a deal, but it could become important later on, like if you start using XML. It's just better to do it correct from the start.
Also, I like to break out of PHP for large blocks of HTML, but that's just because I find it a lot easier to parse.
HTH