0

我正在尝试使用 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.  });
4

1 回答 1

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 
于 2013-03-18T06:05:46.170 回答