Bummer.
So how would I do a query that combines the 2?
I've tried various combinations of AND/OR and I do not get the results I'm looking for
The closest I've come is the following which gets the proper dependentProfiles, but no employeeProfiles (returns the dependent of the employee instead of the employee)
$query2 = "SELECT * FROM employeeProfile,dependentProfile
WHERE (employeeProfile.CompanyID=$CoID OR dependentProfile.CompanyID=$CoID)
AND employeeProfile.COBRA='Yes' AND dependentProfile.COBRA='Yes'
OR
(employeeProfile.CompanyID=$CoID AND employeeProfile.COBRA='Yes')
ORDER BY dependentProfile.EmployeeID";
Here is the print statement:
while($line = mysql_fetch_array($result2))
{
$eeID = $line["EmployeeID"];
$Elast = $line["EmployeeLast"];
$Efirst = $line["EmployeeFirst"];
$dID = $line["DependentID"];
$Dtype = $line["DependentType"];
$Dlast = $line["DependentLast"];
$Dfirst = $line["DependentFirst"];
//?? how do I say 'if dependent/ or 'if employee' ?????
// I use the approach that if $Dtype has a value...do this, else assume type is employee... and do that
// is there a better approach ?????????????
if ( ($Dtype=="Spouse") || ($Dtype=="Minor") || ($Dtype=="Other"))
{
$tableinfo .= "<tr bgcolor=$color>
<td nowrap>$Dtype: $dID</td>
<td nowrap>$Dlast, $Dfirst</td>
</tr>\n";
}
//Otherwise, type is Employee
else
{
$tableinfo .= "<tr>
<td nowrap>Employee: $eeID</td>
<td nowrap>$Elast, $Efirst</td>
</tr>\n";
}
}
print "<table cellpadding=1 cellspacing=1 width=100% border=\"0\" bordercolor=\"#cccccc\">
<tr>
<th align=\"left\" valign=\"bottom\">Type & ID </th>
<th align=\"left\" valign=\"bottom\">Name</th>
</tr>";
print "$tableinfo";
print "</table>";
print "<br>";
Here is the table structure:
dependentProfile
DependentID (auto-increment)
EmployeeID
CompanyID
DependentFirst
DependentLast
COBRA
employeeProfile
EmployeeID (auto-increment)
CompanyID
EmployeeFirst
EmployeeLast
COBRA