2013-03-17 49 views
0

我正在嘗試使用2個MySQL查詢(標頭爲1,內容爲1)和PHP製作手風琴菜單。下面是我的代碼PHP和JQuery代碼,我似乎無法弄清楚如何使內容保留在標題內。 MySQL中的所有內容都按順序打印出來。任何幫助將不勝感激。JQuery手風琴菜單使用MySQL查詢和PHP

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. }); 

回答

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 
+0

感謝我真的需要這裏更多的div添加 – user2180101 2013-03-18 06:08:05