I have the following query
[CODE]
function getAllSerialData_serials() {
$SERIALS = array();
$query = mysql_query(“SELECT * FROM serials
LEFT JOIN serialowners
ON serials.serialNum =serialowners.serialNum
“);
$num_rows = mysql_num_rows($query);
if($num_rows > 0) {
while($ROW = mysql_fetch_array($query, MYSQL_ASSOC)) {
$SERIALS[] = $ROW;
}
}
return $SERIALS;
}
serials table includes id (primary), serialNum
serialowners table includes id(primary), serialNum, fName, lName, un, pw, email, etc
In a loop I display the data
[CODE]
$serialData = getAllSerialData_serials();
foreach($serialData as $serial) { ?>
<tr class=”smFont”><td rowspan=”3″ valign=”top”><?=$serial[‘serialNum’];?></td>
<td rowspan=”3″>
<?=$serial[‘lName’];?>, <?=$serial[‘fName’];?><br />
Email: <a href=”mailto:<?=$serial[’email’];?>” class=’listTitle’><?=$serial[’email’];?></a><br />
</td>
etc, etc….
I want to join these two tables based on serialNum. There will always be a serialNum in the serials table, but not necessarily in the serialowners table.
When I run the query, it is pulling all the data for an entry that has serialNum in both tables, but will not display serialNum from the serials table if there is no joined data in the serialowners table.
I do not understand why it is not displaying the serialNum from the serials table, where there is no join data in the serialowners table.
The loop is displaying the correct number of rows, but rows are blank with no serialNum in the other rows.
Can someone make sense of this for me please?