Well, I have a site where I am in each area using a select, so I think I'm doing more queries than I should, is there any way to get the result done? follows an image of what I'm proposing
<?phptry{$sql="SELECT * FROM anuncios ORDER BY RAND() LIMIT 20";
$stmt = $DB->prepare($sql);
$stmt->bindValue(":Nid", intval($_GET["Nid"]));
$stmt->execute();
$results = $stmt->fetchAll();
} catch (Exception $ex) {
echo $ex->getMessage();
}
foreach ($results as $res) {
$tipo = $res["tipo"];
switch ($tipo) {
case 'Imagem':
echo "<div style='width:720px;height:90px'>
<a href='".$res["codigo"]."' target='_blank'><img src='img/anuncios/".$res["Nid"]."/".$res["arquivo"]."' height='90' width='720'> </a>
</div>";
break;
case 'Flash':
echo "<div style='width:720px;height:90px'>
<embed src='img/anuncios/".$res["Nid"]."/".$res["arquivo"]."' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' height='90' width='720'>
</div>";
break;
case 'Codigo':
echo "<div style='width:100%;height:100px'>
".$res["codigo"]."
</div>";
break;
}
} ?>