Some more questions!
Am I right in thinking that refL1 and refL2 in the games table are the two linesmen?
So if robkir was linesman 1 in a game and in the next linesman 2 your UserID would be stored in the correct column?
If this is the case, can I suggest separating your data even further and creating a 'division' table:
The table field (or columns):
division_id | division_name
...and the content:
1 | 10B
Separating the referee directory, the games, referee types and divisions will make it easier to manage and subsequently fetch and control that data.
So, if you do add the above fields the remaining two tables would like like this:
The ref_directory uses these fields:?
ref_id | ref_name | ref_surname
9 | rob | kir
and the games table:?
game_id | division | ref_center | ref_line1 | ref_line2
1 | 1 | 9 | 19 | 24
Using this database layout the games table becomes the 'heavy lifter' - as you can see each game gets a unique id, the unique division id from the new table is stored in division and for each type of referee the user id is stored - in this instance you were the center ref.
You could also add much more info to the games table - as this will be the one changing the most - maybe game_date, game_location, game_results etc...
Once you have this data, how you pull it out can also change. I would use the games table as the 'base' for any further queries - so simply pull everything out of this and store as an array:
$strSQL = 'SELECT * FROM games';
$rsData = mysql_query($strSQL);
while($row = mysql_fetch_assoc($rsData))
{
$arrData[] = $row;
}
print_r($arrData);
Having access to all of this data is invaluable for creating as many data combinations as you can dream up.
I know this still doesn't answer your question of the foreach, but producing i've found that pumping out clean data is half the battle when building data sets.