Let’s start with a web page that displays brief bios of people drawn from a database, like this:
[B]Muhammad Ali was a world champion boxing champion and one of the most vocal opponents of the war in Vietnam.
Che Guevara was perhaps the most famous Latin American revolutionary of all time.[/B]
To do this, I define the content ($Brief) in a while loop, like this…
$Brief[] = '<div class="Bio"><p><a name="'.$URL.'"></a>'.$row['Brief'].'</p></div>';
Then I put the following on my display page:
echo join( $Brief, '' );
It works fine, but I want to add a line of text below each bio that lists each person’s titles, or classifications. So the display will now look like this:
Muhammad Ali was a world champion boxing champion and one of the most vocal opponents of the war in Vietnam.
African American | activist
Che Guevara was perhaps the most famous Latin American revolutionary of all time.
Latin American | freedom fighter | intellectual
These classification values are stored in a table named people_1_class, which features a separate row for each classification…
URL | Class
Che_Guevara | Latin_American
Che_Guevara | freedom_fighter
Che_Guevara | intellectual
So I create another array…
$Class[] = $row['Class'];
But I don’t know how or where to insert it in my code. Do I change the value of $Brief in my while loop?..
$Brief[] = '<div class="Bio"><p><a name="'.$URL.'"></a>'.$row['Brief'].''.join( $Class, ' | ' ).'</p></div>';
Or do I somehow insert the $Class array on my display page? None of my experiments are working.
This is the entire query…
$res = mysql_query ("SELECT P.URL, P.Title, P.Subtitle, P.MetaTitle, P.MetaDesc, P.KW, P.Site, P.Live,
PB.Common, PB.First, PB.Middle, PB.Last, PB.Prefix, PB.Suffix, PB.Alpha, PB.Born, PB.Died, PB.Birth_Place, PB.Death_Place, PB.Nationality, PC.URL, PC.Class, Brf.URL, Brf.Site, Brf.Brief, ART.Article PXA
FROM people P
LEFT JOIN people_1_bio PB ON PB.URL = P.URL
LEFT JOIN people_1_class PC ON PC.URL = P.URL
LEFT JOIN people_briefs Brf ON Brf.URL = P.URL
LEFT JOIN people_articles_px ART ON ART.URL = P.URL
WHERE P.Site = 'PX' AND Brf.Site = 'PX' AND PB.Alpha LIKE '$MyURL%' AND Brf.Brief !='' AND PC.URL = P.URL AND P.Live = 1
GROUP BY P.URL ORDER BY P.N") or die (mysql_error());
Someone suggested I replace PC.Class with group_concat(PC_Class), but that isn’t working, either.
Thanks for any tips.