I have database which contains persons and every person can have several contacts (for example ICQ, e-mail etc. ). And I need to print this on my page.
I'm working with PostgreSQL database which contains table kontakty and this table have rows with columns id_osoby (foreign key REFERENCES osoby), id_typy_kontaktu (foreign key REFERENCES typy_kontakty) and kontakt .
$stmt = $db->query("SELECT * FROM kontakty WHERE id_osoby = $row[id_osoby]");
$row_kontakty = $stmt->fetch();
$stmt = $db->query("SELECT * FROM typy_kontaktu WHERE id_typy_kontaktu = $row_kontakty[id_typy_kontaktu]");
$row_id_typy_kontaktu = $stmt->fetch();
echo "<tr align='left'>";
echo "<td><span style='color:white'><strong>Kontakt: </strong></span></td>";
echo "<td><em><strong>  $row_id_typy_kontaktu[nazev]:</strong></em> $row_kontakty[kontakt]</td>";
echo "</tr>";
But my code print only one person contact, but persons have several contacts and I need to print all of them.
Hope you understand what I wanted to say. Thx for answers :)
JOINor a second query to get the details.