I want 3 random images, first is working, but the other two just won't work. Preferably, I want to pick 2 other images then the first and the second, and the third to be all different.
Here's my code:
$content .= '<div>';
$qryFirstImage = "SELECT a.KW, a.KWKidsBeschrijving, a.Titel, b.GebruikersNaam
FROM tblKWKids AS a
LEFT JOIN tblUser AS b
ON a.UserID = b.UserID
ORDER BY RAND()";
if ($stmt = mysqli_prepare($dbconn, $qryFirstImage)) {
mysqli_stmt_bind_result($stmt, $KW, $KWKidsBeschrijving, $TitelKW, $GebruikersNaam);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
mysqli_close($dbconn);
}
$content .= '<img src="' . $KW . '" width="240px" height="240px" alt="' . $TitelKW . '" title="' . $TitelKW . '">';
$content .= '<h5>' . $TitelKW . ' door: ' . $GebruikersNaam . '</h5>';
$content .= '<p>' . $KWKidsBeschrijving . '</p>';
$content .= '</div>';
$content .= '<div>';
$qrySecondImage = "SELECT a.KW, a.KWKidsBeschrijving, a.Titel, b.GebruikersNaam
FROM tblKWKids AS a
LEFT JOIN tblUser AS b
ON a.UserID = b.UserID
ORDER BY RAND()";
if ($stmt2 = mysqli_prepare($dbconn, $qrySecondImage)) {
mysqli_stmt_bind_result($stmt2, $KW2, $KWKidsBeschrijving2, $TitelKW2, $GebruikersNaam2);
mysqli_stmt_execute($stmt2);
mysqli_stmt_fetch($stmt2);
}
$content .= '<img src="' . $KW2 . '" width="240px" height="240px" alt="' . $TitelKW2 . '" title="' . $TitelKW2 . '">';
$content .= '<h5>' . $TitelKW2 . ' door: ' . $GebruikersNaam2 . '</h5>';
$content .= '<p>' . $KWKidsBeschrijving2 . '</p>';
$content .= '</div>';
$content .= '<div>';
$qryThirdImage = "SELECT a.KW, a.KWKidsBeschrijving, a.Titel, b.GebruikersNaam
FROM tblKWKids AS a
LEFT JOIN tblUser AS b
ON a.UserID = b.UserID
ORDER BY RAND()";
if ($stmt3 = mysqli_prepare($dbconn, $qryThirdImage)) {
mysqli_stmt_bind_result($stmt3, $KW3, $KWKidsBeschrijving3, $TitelKW3, $GebruikersNaam3);
mysqli_stmt_execute($stmt3);
mysqli_stmt_fetch($stmt3);
}
$content .= '<img src="' . $KW3 . '" width="240px" height="240px" alt="' . $TitelKW3 . '" title="' . $TitelKW3 . '">';
$content .= '<h5>' . $TitelKW3 . ' door: ' . $GebruikersNaam3 . '</h5>';
$content .= '<p>' . $KWKidsBeschrijving3 . '</p>';
$content .= '</div>';