Ceva de genul am facut si eu si a mers!

Cod PHP:
$fetch "select imgId from ipvote where ip='$ip'";
$resultf mysqli_query($connect$fetch);
$sql "SELECT id,title,filename,voteNr,voteValue FROM images INNER JOIN vote ON id = imgId WHERE ";
while (
$q mysqli_fetch_array($resultf)) {
$id $q['imgId'];
$sql .= "id!='$id' and ";
}
$sql .= " enabled='yes' ORDER BY rand() LIMIT 1"
Multumesc oricum la toti cei care au raspuns