Imagine a table (sm_ppl) with the following fields and just one row, as follows:
URL / Name_First / Name_Middle / Name_Last
Hiram_Gill / Hiram / (NULL) / Gill
Another table - sm_ppl_mayor - lists the dates Gill served as mayor, along with some other information, as follows:
URL / Term_Began / Term_Ended / Party
Hiram_Gill / 1910 / 1912 / Republican
Sam_Smith / 1912 /1914 / Democrat
Hiram_Gill / 1914 / 1916 / (NULL)
PHP Code:
$res = mysql_query ("SELECT SMP.N, SMP.URL, SMP.Name_First, SMP.Name_Middle, SMP.Name_Last,
SMGov.URL URL_G, SMGov.Term_Began, SMGov.Term_Ended, SMGov.Party G_P, SMGov.Notes, SMGov.Image,
SMM.URL URL_M, SMM.Term_Began TermB, SMM.Term_Ended TermE, SMM.Party M_P, SMM.Notes M_N, SMM.Image ImageM,
SMW.URL, SMW.Class,
SMWA.URL, SMWA.Org, SMWA.Title, SMWA.Year_Began, SMWA.Year_Ended, SMWA.Year_Mid
FROM sm_ppl SMP
LEFT JOIN sm_ppl_gov SMGov ON SMGov.URL = SMP.URL
LEFT JOIN sm_ppl_mayor SMM ON SMM.URL = SMP.URL
LEFT JOIN sm_ppl_wrrs SMW ON SMW.URL = SMP.URL
LEFT JOIN sm_ppl_wrrs_assoc SMWA ON SMWA.URL = SMP.URL
WHERE SMP.URL = '$MyURL'
ORDER BY N") or die (mysql_error());
while ($row = mysql_fetch_array ($res))
{
$NameFirst = $row['Name_First'];
$NameMiddle = $row['Name_Middle'];
$NameLast = $row['Name_Last'];
$NameFull = ''.$NameFirst.' '.$NameMiddle.' '.Name_Last.'';
$PartyM = $row['M_P'];
$TermB = $row['TermB'];
$TermE = $row['TermE'];
echo $NameFull;
echo $Party;
echo ''.$TermB.'-'.$TermE.'';
}
The echo statements at the end of my script display the following:
Code:
Hiram C. Gill
Republican
1910-1911Hiram C. Gill
1914-1918
How can I modify my script so it displays the following?:
Code:
Hiram C. Gill (Republican, 1910-1911, 1914-1918)
...or this:
Code:
Hiram C. Gill (Republican), Mayor: 1910-1911, 1914-1918
Thanks.
Bookmarks