Display content from two tables in a accordion for your ID

Asked

Viewed 40 times

1

I have two tables:

  • the first is temporadas, that hold only the name of the season. Example: Primeira Temporada, Segunda Temporada, etc..
  • I have another table that holds each episode for its season.

The episodes are shown in a accordion effect, the name Primeira Temporada is the link of the accordion effect, there I have the div conteudo that will hold the episodios for each season.

What I’m struggling with is showing each episode in its season on the accordion effect.

I don’t pass the id_temporada in the URL

<?php   
$url = explode("/",$_GET['url'],-1);
$url = $url[1];
if(isset($_GET['id_serie'])){
    $id_serie = $_GET['id_serie'];
}
$temporada = "SELECT * FROM temporadas WHERE id_serie = '$url' AND audio = 'Dublado'";
$temporadaShow = mysqli_query($conn,$temporada);
while($show = mysqli_fetch_assoc($temporadaShow)){  
?>
    <div class="caixa align_left">
    <!-- Exibo o nome da temporada -->
    <a href="javascript:void(0)" class="titulo" id="<?php echo $show['id_temporada'];?>">
         <?php echo $show['temporada_serie'];?>
    </a>
    <!-- div que vai segurar os episodio no meu efeito sanfona -->
    <div class="conteudo hide" id="<?php echo $show['id_temporada'];?>">    
        <?php
            if(isset($_GET['id_temporada'])){
                $id_temporada = $_GET['id_temporada'];
            }
            $episodio = "SELECT * FROM episodios WHERE id_temporada = '$id_temporada' AND audio = 'Dublado'";
            $episodioShow = mysqli_query($conn,$episodio);
            while($show = mysqli_fetch_assoc($episodioShow)){
                 echo "aqui eu exibiria o episodio";
            }
        ?>
    </div>
</div>
<?php }?>
  • 1

    I deleted my comment since you solved that.

  • Why don’t you use the id_serie in your query?

  • @VWE the id_serie is auto increment, which corresponds to the season is the id_temporada, if you want I can put the structures of my tables

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.