$sql_locations = "SELECT officelocations_tbl.*,
sf1.firstName AS c1Firstname, sf1.lastName AS c1lastName, sf1.middleInitial AS c1middleInitial, sf1.suffix AS c1suffix, sf1.accredations AS c1accredations,
sf2.firstName AS c2Firstname, sf2.lastName AS c2lastName, sf2.middleInitial AS c2middleInitial, sf2.suffix AS c2suffix, sf2.accredations AS c2accredations,
sf3.firstName AS c3Firstname, sf3.lastName AS c3lastName, sf3.middleInitial AS c3middleInitial, sf3.suffix AS c3suffix, sf3.accredations AS c3accredations,
city_tbl.*, state_tbl.*
FROM officelocations_tbl
JOIN city_tbl ON (officelocations_tbl.cityID = city_tbl.cityID)
JOIN state_tbl ON (officelocations_tbl.stateID = state_tbl.stateID)
JOIN staff_tbl sf1 ON (sf1.staffID = officelocations_tbl.contact1)
JOIN staff_tbl sf2 ON (sf2.staffID = officelocations_tbl.contact2)
JOIN staff_tbl sf3 ON (sf3.staffID = officelocations_tbl.partner)";
$result_loc = mysql_query($sql_locations);
while ($db_field = mysql_fetch_assoc($result_loc)) {
if ($db_field['c2Firstname'] == ""){
print $db_field['officeName'] . "<BR>";
print $db_field['address1'] . "<BR>";
print $db_field['cityName'] . ", " . $db_field['state_abreviation'] . " " . $db_field['zipCode']."<BR>";
print $db_field['c1Firstname'] . " " . $db_field['c1lastName'] . " ". $db_field['c1middleInitial'] . " ". $db_field['c1suffix']. " ". $db_field['c1accredations'] . "<BR><BR><BR><BR>";
print $db_field['c3Firstname'] . " " . $db_field['c3lastName'] . " ". $db_field['c3middleInitial'] . " ". $db_field['c3suffix']. " ". $db_field['c3accredations'] . "<BR>";
}else if ($db_field['c2Firstname'] != ""){
print $db_field['officeName'] . "<BR>";
print $db_field['address1'] . "<BR>";
print $db_field['cityName'] . ", " . $db_field['state_abreviation'] . " " . $db_field['zipCode']."<BR>";
print $db_field['c1Firstname'] . " " . $db_field['c1lastName'] . " ". $db_field['c1middleInitial'] . " ". $db_field['c1suffix']. " ". $db_field['c1accredations'] . "<BR>";
print $db_field['c2Firstname'] . " " . $db_field['c2lastName'] . " ". $db_field['c2middleInitial'] . " ". $db_field['c2suffix']. " ". $db_field['c2accredations'] . "<BR>";
print $db_field['c3Firstname'] . " " . $db_field['c3lastName'] . " ". $db_field['c3middleInitial'] . " ". $db_field['c3suffix']. " ". $db_field['c3accredations'] . "<BR><BR><BR><BR>";
}
This does display the contact information for sf1 it is only showing 2 entries when there should be 13. I have a total of 29 locations that I want to be able to display, not all locations have contact1 or contact2 but all have a partner.
I tried to edit the if statement like this:
if ($db_field['c1Firstname'] != "" && $db_field['c2Firstname'] == "")
but that didn't work either still only the ones with contact1, contact2 and partner show. I want it to display the locations and each persons name that is associated with that location below the address.

New Topic/Question
Reply


MultiQuote



|