I have 3 MySQL tables, Trophies, Winners and LinkTable I need to output the results in a way that all the previous winners of each trophy will be listed under each trophy because currently each result is just looping giving me a ton on data.
Trophies Winners LinkTable
-------- --------- ---------
TrophyID WinnerID LT_WinnerID
TrophyName WinnerName LT_TrophyID
Description Year
Image
SQL Join is as follows
$trophylist = mysql_query("
SELECT TrophyID, TrophyName, Description, Image, WinnerID, WinnerName, Year
FROM LinkTable
INNER JOIN Winners ON (LinkTable.LT_WinnerID = Winners.WinnerID)
INNER JOIN Trophies ON (LinkTable.LT_TrophyID = Trophies.TrophyID)");
If i output the results through a while loop, as expected returns a new line for each winner with the trophy alongside it.
I think it is a foreach loop that I need to use so that an array can be created for the trophy, but Im a little stuck for ideas now as everything I'm finding doesnt seem to make much sense so anybody pointing me in the right direction would be greatly appreciated.
foreach?whileloop you have so far? How are you outputting the results? You can create an array using awhileloop, too.$rowand add them into the array that you want.