php循环导致手风琴面板一次打开

时间:2014-09-19 02:10:37

标签: javascript php accordion

我有一个手风琴面板,可以在它的html表单中正常运行,这意味着一次只能打开一个标签。但它被添加到一个php循环中,现在当你点击一个标签时,活动类被添加到它们中,所有这些都导致它们一次打开。有没有办法来解决这个问题?我没有编写PHP代码,后端开发人员也没有,但目前他无法帮助我解决这个问题。

这是代码的样子 `

              for ($i = 0; $i < count($secs); $i++)
              {
                $sid = $secs[$i]->getid();
        // multiple replace due to conversion from plain textarea
        // to wysywig textarea (ckeditor); has to be "\r" & not '\r'
                $intro =
                str_replace("\r", "<br/>",
                    str_replace("<p>\r", "<p>",
                        (str_replace("</p>\r", "</p>",
                            $secs[$i]->getintro()))));

                if ((isset($intro) && ("x$intro" != "x")))
                {
                    ?>
            <section class="content large-8 columns">


              <p><?php echo $intro; ?></p>

              <?php
            }
          }
          $acsection = new acsection();
          $secs = $acsection->selectBy("((intro is null) or (length(intro) = 0)) "
           . "and user_id=".$ruid.
           " order by display_order,createdate");
           ?>
           <!-- <br/> -->
           <?php
           for ($i = 0; $i < count($secs); $i++)
           {
            $title = convert_smart_quotes($secs[$i]->gettitle(), 1);
          // multiple replace due to conversion from plain textarea
          // to wysywig textarea (ckeditor); has to be "\r" & not '\r'
            $content =
            str_replace("\r", "<br/>",
             str_replace("<p>\r", "<p>",
              (str_replace("</p>\r", "</p>",
               $secs[$i]->getcontent()))));
            if ((((isset($_SESSION['user_id'])) &&
                ($uid == $_SESSION['user_id'])) || //user or admin
             ((isset($_SESSION['admin']))
              && ($_SESSION['admin'] == 1)))
             && ($preview != 1))
            {
             ?>

             <div class="controls">
              <div class="delete">
               <a href="javascript:confirmDelete('manage-sections.php?sid=<?php echo $secs[$i]->getid(); ?>&uid=<?php echo $uid; ?>&cat=s&action=delete')">Delete current section</a>
             </div>
             <div class="edit">
               <a href="manage-sections.php?sid=<?php echo $secs[$i]->getid(); ?>&uid=<?php echo $uid; ?>&cat=s&action=edit">Edit current section</a>
             </div>
           </div>
           <?php
         }
         if ((isset($title) && ("x$title" != "x")))
         {
           ?>

           <dl class="accordion" data-accordion>
             <dd class="accordion-navigation">
              <a href="#panel1"><?php echo (isset($title) && ("x$title" != "x")) ? $title : "" ?></a>
              <div id="panel1" class="content" style="padding-left:3%;">
               <?php
             }
             if ((isset($content) && ("x$content" != "x")))
             {
               ?>
               <div class="content">
                <p class="accordin-content"><?php echo (isset($content) && ("x$content" != "x")) ? $content : "" ?></p>
              </div>
            </div>
          </dd>
          <?php
        }
      }
      echo "\n";
  } // while
  ?>


</dl> <!-- End of Accordian Tabs -->

`

我对php或后端开发不是很好,所以任何帮助都非常感谢。

1 个答案:

答案 0 :(得分:0)

听起来问题是每个标签具有相同的ID,因此当active类应用于该标识时,它会应用于每个标签。