使用MySQL查询和PHP的JQuery手风琴菜单

时间:2013-03-17 19:42:52

标签: jquery mysql

我正在尝试使用2个MySQL查询(1个用于标题,1个用于内容)和PHP来制作手风琴菜单。下面是我的代码PHP和JQuery代码,我似乎无法弄清楚如何使内容保持在标题内。 MySQL中的所有内容都按顺序打印出来。任何帮助将不胜感激。

PHP和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(){245.      $('.menu').accordion();246.  });

1 个答案:

答案 0 :(得分:0)

您需要添加更多div

下面

    <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