Forum Moderators: mack
I need some help to make sql query
My database table contains game_name and player_name
And it looks someting like this -
football - tim
football - jim
volleyball - jow
volleyball - joe
and etc
now i want that my first sql_query should show the game_name and when i click on that link it should show the players name in the game
like if i click on link_football it should list the players in it and when i click on volleyball it should show the list of players in this game.
HS
“Game_name”
gm_id (pk)
name
“player_name”
pm_id (pk)
name
gm_id (fk)
Query 1
SELECT * FROM Game_name
Query 2
SELECT * FROM “player_name”
WHERE gm_id = X
X = a url parameter from your first query.
Without knowing exactly hat you are after, this may not be exactly what you want but the principle of linking tables/records by the FK (foreign key) should be evident.
$game_name=$_REQUEST['gamename']
$result=mysql_query("select player_name from games where game_name='$game_name'");
echo "<h1>Players for game: $game_name</h1><br><ul>";
while(list($player_name))= mysql_fetch_row($result))
{
echo "<li>$player_name\n";
}
?>
</ul>
[example.com...]
Hope I'm not doing someone's homework.