0
I want to place the three columns to show your results, all within the same WHILE, as I should do?
$movies = $db->query('SELECT * FROM movies AS M, highlights AS H, images AS I
WHERE (M.movie_key = H.featured_key AND I.images_key = M.movie_key) AND (I.images_type = H.featured_type) AND H.featured_status = "ativo"
ORDER BY H.featured_id DESC LIMIT 5');
$series = $db->query('SELECT * FROM series AS S, highlights AS H, images AS I
WHERE (S.serie_key = H.featured_key AND I.images_key = S.serie_key) AND (I.images_type = H.featured_type) AND H.featured_status = "ativo"
ORDER BY H.featured_id DESC LIMIT 5');
$animes = $db->query('SELECT * FROM animes AS A, highlights AS H, images AS I
WHERE (A.anime_key = H.featured_key AND I.images_key = A.anime_key) AND (I.images_type = H.featured_type) AND H.featured_status = "ativo"
ORDER BY H.featured_id DESC LIMIT 5');
if($movies->rowCount() != 0){
while($database = $movies->fetch())
{
echo '<article class="item" id="post-'.$database['movie_key'].'">
<div class="image">
<a href="/assistir/filme/'.$database['movie_url'].'">
<img src="'.$database['images_slide'].'" alt="'.$database['movie_name'].'">
</a>
<a href="/assistir/filme/'.$database['movie_url'].'">
<div class="data">
<h3 class="title">'.$database['movie_name'].'</h3>
<span>'.$database['movie_year'].'</span>
</div>
</a>
<span class="item_type">FILME</span>
</div>
</article>';
}
}
if($series->rowCount() != 0){
while($database = $series->fetch())
{
echo '<article class="item" id="post-'.$database['serie_key'].'">
<div class="image">
<a href="/assistir/serie/'.$database['serie_url'].'">
<img src="'.$database['images_slide'].'" alt="'.$database['serie_name'].'">
</a>
<a href="/assistir/serie/'.$database['serie_url'].'">
<div class="data">
<h3 class="title">'.$database['serie_name'].'</h3>
<span>'.$database['serie_year'].'</span>
</div>
</a>
<span class="item_type">SÉRIE</span>
</div>
</article>';
}
}
if($animes->rowCount() != 0){
while($database = $animes->fetch())
{
echo '<article class="item" id="post-'.$database['anime_key'].'">
<div class="image">
<a href="/assistir/anime/'.$database['anime_url'].'">
<img src="'.$database['images_slide'].'" alt="'.$database['anime_name'].'">
</a>
<a href="/assistir/anime/'.$database['anime_url'].'">
<div class="data">
<h3 class="title">'.$database['anime_name'].'</h3>
<span>'.$database['anime_year'].'</span>
</div>
</a>
<span class="item_type">ANIME</span>
</div>
</article>';
}
}
Isn’t there a relationship between the tables Movies , series and anime ? If it exists because it is using three queries to the database could mount only one query.
– Rafael Salomão