Forum Moderators: coopster
I have a database which records details of Official appointments to soccer games. I want to be able to show all games in the database along with the Officials that have been appointed to the games.
My question is, how do I get values from 4 seperate queries to show in one recurring php table?
When all the data is shown together I would like the following to be displayed:
game_id, team_1, team_2, venue, date, competition, referee, asst1, asst2, 4th official - then this row repeats for each game.
Any help is much appreciated as I am totally stuck here.
My DB is organised with the following tables:
official: game_id, official_type, ref_id
official_type: name_id, name
referee: ref_id, name
games: game_id, team_1, team_2, venue, date, competition
The links between the tables are:
games.game_id - official.game_id
official.official_type - official_type.name_id
official.ref_id - referee.ref_id
I extract all the data from the games table with
$sql = mysql_query("select game_id, team_1, team_2, date, venue, competition from ref_games") or die(mysql_error()); I get which referee is associated with that game with
$sql2 = mysql_query("SELECT ref_referee.name FROM ((ref_games INNER JOIN ref_official ON ref_games.game_id=ref_official.game_id) INNER JOIN ref_officialtype ON ref_official.official_type=ref_officialtype.name_id) INNER JOIN ref_referee ON ref_official.ref_id=ref_referee.ref_id WHERE (((ref_games.game_id)='$game_id') And ((ref_games.game_id)=ref_official.game_id) And ((ref_referee.ref_id)=ref_official.ref_id)) AND ((ref_official.official_type)='1'))"); (I use the same code to get the other 3 officials)
Something like the above. You can convert it to INNER joins.
If I misunderstood you, let me know.