Both of your answers combined gave me the result, thank you!
This is my final coding:
$part = $_REQUEST['id'];
if(isset($_GET["id"])){
$conn = mysql_connect("localhost","USERNAME","PASSWORD");
mysql_select_db("DATABASE",$conn);
$query = sprintf("SELECT * FROM `quack`
WHERE idquack='%s'",
mysql_real_escape_string($part));
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid or no security key!';
die($message);
} else {
while ($row = mysql_fetch_assoc($result)) {
if ($row['Metgesel'] != "*"){
if ($row['Metgesel'] == "#"){
if ($row['Kind1'] != "*"){
if ($row['Kind2'] != "*"){
echo '<h1>' . $row['Naam'] . ", " . "Metgesel" . ", " . $row['Kind1'] . " en " . $row['Kind2'] . "</h1>";
} else {
echo '<h1>' . $row['Naam'] . ", " . "Metgesel" . " en " . $row['Kind1'] . "</h1>";
}
} else {
echo '<h1>' . $row['Naam'] . " en " . "Metgesel" . "</h1>";
}
} else{
if ($row['Kind1'] != "*"){
if ($row['Kind2'] != "*"){
echo '<h1>' . $row['Naam'] . ", " . $row['Metgesel'] . ", " . $row['Kind1'] . " en " . $row['Kind2'] . "</h1>";
} else {
echo '<h1>' . $row['Naam'] . ", " . $row['Metgesel'] . " en " . $row['Kind1'] . "</h1>";
}
} else {
echo '<h1>' . $row['Naam'] . " en " . $row['Metgesel'] . "</h1>";
}
}
} else {
echo '<h1>' . $row['Naam'] . "</h1>";
}
echo '<script>invite();</script>';
}
}
mysql_free_result($result);
} else{
echo ''n Fout het voorgekom! Jammer daarvoor. Jy sal nou na die tuisblad geneem word.';
echo '<script>returnHome();</script>';
}