I'm using this code to show similar entry's to the one that's currently showing.
$result2 = mysql_query("SELECT * FROM planten WHERE cat = '$cat' ORDER BY rand() limit 3")
or die(mysql_error());
while($row2 = mysql_fetch_array($result2)) {
$naam_gerelateerd = $row['naam'];
$mintemp = $row['mintemp'];
echo $naam_gerelateerd;
}
Now I get 3 times the same echo.
(Lets say my current page is "Product 1", this box should show 3 similar products. But currently it echo's 3x "Product 1")
Also, how can I make my code sql-injection-protected? I've read something about PDO, but how safe is this?
Thanks in advance!