Ik heb een WK database met 29 tabellen waarin data zitten. (1930 t/m 2018, 2022 Qatar komt er nog aan). Tussen de tabellen zitten FOREIGN KEYS voor ID's.
Ik wil graag deze data presenteren op een website (via PHP script) en dat lukt prima als het gaat om één tabel.
In verschillende tabellen zitten team_id's weergeven als T-80 i.p.v. de naam van het team. In de teams tabel staat T-80 voor Uruguay (teams.team_name)
Op welke manier kan ik de team naam (team_name) laten verschijnen op de pagina tour.php welke komt uit de andere tabel teams.team_name?
Hieronder de twee PHP pagina's als URL. De tabellen op de pagina komen exact overeen met de tabelstructuur namen.
Pagina (tabel) tournament_standings ()
Pagina (tabel) teams ()
P.s. als iemand interesse heeft in de WK data dan kan ik een SQL script sturen welke je zo kunt inladen in PhPMyAdmin. Stuur mij een DM ;-)
Deel van HTML/PHP code van tour.php
<table class="table table-bordered">
<thead>
<tr>
<th>tournament_id</th>
<th>position</th>
<th>team_id</th>
</tr>
</thead>
<tbody>
<?php
$con = mysqli_connect('db.voetbalmatch.eu', 'mdxxx', 'xxxxxxxxx', 'mdxxx');
$query = "SELECT *
FROM tournament_standings
WHERE position < '4'
ORDER BY tournament_id ASC";
$query_run = mysqli_query($con, $query);
if(mysqli_num_rows($query_run) > 0)
{
foreach($query_run as $row)
{
?>
<tr>
<td><?= $row['tournament_id']; ?></td>
<td><?= $row['position']; ?></td>
<td><?= $row['team_id']; ?></td>
</tr>
<?php
}
}
else
{
?>
<tr>
<td colspan="4">No Record Found</td>
</tr>
<?php
}
?>
</tbody>
</table>Deel van HTML/PHP code van teams.php
<table class="table table-bordered">
<thead>
<tr>
<th>team_id</th>
<th>team_name</th>
<th>team_code</th>
<th>federation_name</th>
<th>region_name</th>
<th>confederation_id</th>
<th>team_wikipedia_link</th>
<th>federation_wikipedia_link</th>
</tr>
</thead>
<tbody>
<?php
$con = mysqli_connect('db.voetbalmatch.eu', 'mdxxx', 'xxxxxxxxx', 'mdxxx');
$query = "SELECT * FROM teams";
$query_run = mysqli_query($con, $query);
if(mysqli_num_rows($query_run) > 0)
{
foreach($query_run as $row)
{
?>
<tr>
<td><?= $row['team_id']; ?></td>
<td><?= $row['team_name']; ?></td>
<td><?= $row['team_code']; ?></td>
<td><?= $row['federation_name']; ?></td>
<td><?= $row['region_name']; ?></td>
<td><?= $row['confederation_id']; ?></td>
<td><?= $row['team_wikipedia_link']; ?></td>
<td><?= $row['federation_wikipedia_link']; ?></td>
</tr>
<?php
}
}
else
{
?>
<tr>
<td colspan="4">No Record Found</td>
</tr>
<?php
}
?>
</tbody>
</table>