$inter = $pdo->query("SELECT * FROM noticias WHERE status = 'ativo' AND fixo != 's' AND comentarios != 's' ORDER BY id DESC LIMIT 5");
$i = 1;
$num = '';
while($in = $inter->fetch()) {
if($i == 1){
$num .= "'".$in['id']."', ";
}elseif($i == 2){
$num .= "'".$in['id']."', ";
}elseif($i == 3){
$num .= "'".$in['id']."', ";
}elseif($i == 4){
$num .= "'".$in['id']."', ";
}elseif($i == 5){
$num .= "'".$in['id']."'";
}
$noticias = $pdo->query("SELECT * FROM noticias WHERE status='ativo' AND cat_id='Notícias' AND fixo != 's' AND comentarios != 's' AND id NOT IN ( $num ) ORDER BY id DESC LIMIT 3");
echo $num;
$i++;}
while ($not = $noticias->fetch(PDO::FETCH_ASSOC)) {
The error happens in where AND id NOT IN ($ num), since $ num is not working in NOT IN, but is normal in echo, how to solve?