Hi,
I'm trying to figure out how to combine while loops to get the following results:
Employee Name | Marital Status | List Dependents
Employee A Family Dependent A, DependentB
Employee B Single n/a
I'm able to get the employee list to print, but I don't know how to list the dependents. Right now, all I do is show a link to either ADD or VIEW dependents, i.e.
Employee Name | Marital Status | List Dependents
Employee A Family ADD or VIEW
Here is the code:
/* assume code is here to query Db, and fetch results for employee */
while($line = mysql_fetch_array($result2))
{
$EEid = $line["EmployeeID"];
$last = $line["EmployeeLast"];
$first = $line["EmployeeFirst"];
$status = $line["MaritalStatus"];
if( $c == 0 ){
$color = "dddddd";
$c = 1;
}else{
$color = "white";
$c = 0;
}
//If employee is single
if ($status=="Single")
{
$tableinfo .= "<tr bgcolor=$color>
<td nowrap>$last, $first</td>
<td nowrap>$status</td>
<td nowrap class=\"small\">n/a</td><td nowrap class=\"small\">n/a</td>
</tr>\n";
}
//If employee = family
if ($status=="Family")
{
$tableinfo .= "<tr bgcolor=$color>
<td nowrap>$last, $first</td>
<td nowrap>$status</td>
<td align=\"center\"><A HREF=\"dependents_add.php?id=$EEid\">ADD</A> or <A HREF=\"dependents.php?id=$EEid\">View</A></td></td>
</tr>\n";
}
print "<table cellpadding=1 cellspacing=1 width=100% border=\"0\" bordercolor=\"#cccccc\">
<tr>
<th align=\"left\" valign=\"bottom\">Name</th>
<th nowrap align=\"left\" valign=\"bottom\">Marital Status</th>
<th valign=\"bottom\">Dependents</th>
</tr>";
print "$tableinfo";
print "</table>";
print "<br>";
print "<center><table>";
I understand how to create the 2nd While Loop to get the list of dependents, but how would I do the Print statements?
I'm at a loss so help is appreciated.