0
Well I have a site where I am to each area using a select , I think I’m making more queries than I should, is there any way to repeat the result ? follows a picture of what I am proposing
<?php
try {
$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;
}
} ?>
in this case then in each result would have to use the right switch? because I need to separate the type of each one before , it would not be possible to already take all this check and put the result inside another array?
– Arsom Nolasco
From what I understood from the code you posted, the switch is necessary due to the type of banner. As it can be text, image or flash. This switch has to keep. But the focus in question is on how to print the ads between the text and html of the page, right?
– Daniel Omine
Yes, I’ll ask another question by being more detailed
– Arsom Nolasco