Jump to content

JQuery accordion menu using MySQL queries and PHP


st0ked56

Recommended Posts

Hello,

 
I am trying to make an accordion menu using 2 MySQL queries (1 for the header and 1 for the contents) and PHP.  Below is my code PHP and JQuery code, I can't seem to figure out how to make the contents stay inside the headers.  Everything from the MySQL prints out in order.  Any help would be greatly appreciated.
 
PHP and MySQL
 <div id="left">
  <div class="menu">
<?php
  $sqlseasons = "SELECT * FROM seasons";
  $resultseasons = mysqli_query($dbc, $sqlseasons);
  while ($row = mysqli_fetch_array($resultseasons)){  
  $year_id = $row['year_id'];
?>
    <h3><?php echo $row['seasonyear'] ?></h3>
    <?php 
      $sqlteam = "SELECT team.team_id, team.year_id, team.teamname 
                  FROM team 
                  WHERE team.year_id = '$year_id'";
      $resultsteam = mysqli_query($dbc, $sqlteam);
      while ($sqlrow = mysqli_fetch_array($resultsteam)){
        $teamid = $sqlrow['team_id'];
    ?>
        <p><a href="#" onclick="displaySeason('<?php echo $teamid ?>')" id="menu_teamname"><?php echo $sqlrow['teamname']; ?></a></p>
<?php
     }
     mysqli_close();
 }
 mysqli_close();
?>
</div>
<button id="team-season">Add Team</button>

JQuery

 $(document).ready(function(){
      $('.menu').accordion();
  });

 

 

 

Attached is a picture of a menu describing what I am trying to do.

 

Thank you for the help,

Mike

 

 

 

post-143625-0-19311200-1363484376_thumb.png

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.