Php 滚动MySQL数据时显示正确的选项卡

Php 滚动MySQL数据时显示正确的选项卡,php,mysql,back,forward,Php,Mysql,Back,Forward,我有一个页面,由三个标签组成,每个标签上都有标签。单击标签将打开每个选项卡(通过显示/隐藏div)。每个选项卡都包含MySQL数据,每个选项卡底部都有箭头,用于进入下一个数据“页面” 我的问题是,当您单击箭头时,页面确实会转到下一个数据页面,但是默认选项卡(tab1)是可见的,而其他两个是隐藏的,因此如果您在选项卡2上,点击下一个箭头,您将返回到tab1,并且必须点击tab3才能查看数据 更改选项卡可见性的脚本如下所示: <script type="text/javascript">

我有一个页面,由三个标签组成,每个标签上都有标签。单击标签将打开每个选项卡(通过显示/隐藏div)。每个选项卡都包含MySQL数据,每个选项卡底部都有箭头,用于进入下一个数据“页面”

我的问题是,当您单击箭头时,页面确实会转到下一个数据页面,但是默认选项卡(tab1)是可见的,而其他两个是隐藏的,因此如果您在选项卡2上,点击下一个箭头,您将返回到tab1,并且必须点击tab3才能查看数据

更改选项卡可见性的脚本如下所示:

<script type="text/javascript">
$(document).ready(function () {
    $("div.tab-headers>a").click(function () {
        // Grab the href of the header
        var _href = $(this).attr("href");

        // Remove the first character (i.e. the "#")
        _href = _href.substring(1);

        // show this tab
        tabify(_href);
    });
    tabify();
});

function tabify(_tab) {
    // Hide all the tabs
    $(".tab").hide();

    // If valid show tab, otherwise show the first one
    if (_tab) {
        $(".tab a[name=" + _tab + "]").parent().show();
    } else {
        $(".tab").first().show();
    }
}

// On page load...
$(document).ready(function () {
    // Show our "default" tab.
    // You may wish to grab the current hash value from the URL and display the appropriate one
    tabify();
});
</script>

$(文档).ready(函数(){
$(“div.tab-headers>a”)。单击(函数(){
//抓取标题的href
var_href=$(this.attr(“href”);
//删除第一个字符(即“#”)后
_href=_href.子字符串(1);
//显示此选项卡
tabify(_href);
});
tabify();
});
函数选项卡化(_选项卡){
//隐藏所有标签
$(“.tab”).hide();
//如果“显示”选项卡有效,则显示第一个选项卡
如果(_选项卡){
$(“.tab a[name=“+\u tab+”])。父项().show();
}否则{
$(“.tab”).first().show();
}
}
//页面加载时。。。
$(文档).ready(函数(){
//显示我们的“默认”选项卡。
//您可能希望从URL中获取当前哈希值并显示相应的哈希值
tabify();
});
tab2的代码是:

<div class="tab">
<a name="tab2"></a>
<img src="images/glossary_shiptype.png" width="1643" height="952" /> 

  <div class="glossary_body">
  <table width="740" border="0">
    <?php do { ?>
      <tr>
        <td><?php echo $row_ship_type['term']; ?>:</td>
        <td><?php echo $row_ship_type['definition']; ?></td>
      </tr>
      <?php } while ($row_ship_type = mysql_fetch_assoc($ship_type)); ?>
    </table>
  </div>

  <div class="glossary_arrow_back">
  <?php if ($pageNum_ship_type > 0) { // Show if not first page ?>
          <a href="<?php printf("%s?pageNum_ship_type=%d%s", $currentPage, max(0, $pageNum_ship_type - 1), $queryString_ship_type); ?>"><img src="images/arrow_left.png" /></a>
          <?php } // Show if not first page ?>
  </div>

  <div class="glossary_arrow_forward">
  <?php if ($pageNum_ship_type < $totalPages_ship_type) { // Show if not last page ?>
          <a href="<?php printf("%s?pageNum_ship_type=%d%s", $currentPage, min($totalPages_ship_type, $pageNum_ship_type + 1), $queryString_ship_type); ?>"><img src="images/arrow_right.png" /></a>
          <?php } // Show if not last page ?>
  </div>
</div>


您好,您必须在paramater#tab1或#tab2或#tab3中传递tab id,如果您在查询字符串中获得#tab2并移动到#tab3,您必须删除#tab2

抱歉,我对所有选项卡的回答有点迷茫,您能突出显示我需要修改的代码区域吗。谢谢您添加了两件事%s和$tab\u id