Andy Hinkle Andy Hinkle - 5 months ago 9
MySQL Question

Two Tables - One Query for PHP output

I have two tables with a left outer join. I'm looking to display information from the two tables using PHP.

Here is my query:

$query = "SELECT headcount.*, empinfo.*
FROM headcount LEFT OUTER JOIN empinfo ON headcount.id = empinfo.id
WHERE empinfo.IsActive = '1'
AND headcount.HomeDept ='Rides 1' ORDER BY headcount.EmployeeName ASC";


Here is the rest of the statement:

IsUnderage is in the empinfo table. EmployeeName, JobTitle is in the headcount table. id match in both tables.

echo "<tr>";
echo '<td>' . $row['EmployeeName'] . '</td>';
echo '<td>' . $row['JobTitle'] . '</td>';
echo '<td>' . $row['IsUnderage'] . '</td>';
echo '<td><a href="edit.php?id=' . $row['id'] . '">Edit</a></td>';
echo "</tr>";


The first two (EmployeeName, JobTitle) work just fine but the IsUnderage does not work. I've tried using $row['empinfo.IsUnderage'] but that does not work either.

Data Dump for one row (* for confidential info):

Array ( [0] => * [EmployeeName] => * [1] => * [DOB] => * [2] => 18 [Age] => 18
[3] => * [StreetAddress] => * [4] => * [City] => * [5] => * [State] => *
[6] => * [ZipCode] => * [7] => * [Email] => * [8] => * [HomePhone] => *
[9] => * [Wireless] => * [10] => * [JobTitle] => * [11] => 7006 [id] => 7006 [12] => * [HomeDept] => *
[13] => * [Manager] => * [14] => 7006 [15] => 1 [isActive] => 1 [16] => 0 [isUnderage] => 0 [17] => [submittedAOHform] =>
[18] => [eightDailyHours] => [19] => [nineDailyHours] => [20] => [schoolWeekThirty] => [21] => [schoolWeekForty] => [22] => [nonSchoolThirty] =>
[23] => [nonSchoolForty] => [24] => [pastTenPM] => )


Any ideas here?

Answer

Replace IsUnderage to isUnderage

 echo '<td>' . $row['isUnderage'] . '</td>';
Comments