gpt4 book ai didi

php - Spry 选项卡式面板不显示动态数据

转载 作者:行者123 更新时间:2023-11-29 14:26:12 25 4
gpt4 key购买 nike

您好,我正在尝试使用动态数据设置 spry 选项卡式面板,我想使用单个查询来完成这项工作,我只在“选项卡 1”、“选项卡 2”、“选项卡 3”中获得结果,但没有显示任何数据,我想我在重复区域中使用 while 循环使用相同的查询三次,这就是发生这种情况的原因,我尝试使用 foreach 循环但没有帮助,这是我到目前为止的测试代码,请建议什么是正确的方法来做到这一点。

谢谢。

我的 spry 选项卡式面板代码是这样的。

<div id="TabbedPanels1" class="TabbedPanels">
<ul class="TabbedPanelsTabGroup">
<li class="TabbedPanelsTab" tabindex="0">Tab 1</li>
<li class="TabbedPanelsTab" tabindex="0">Tab 2</li>
<li class="TabbedPanelsTab" tabindex="0">Tab 3</li>
</ul>
<div class="TabbedPanelsContentGroup">

<div class="TabbedPanelsContent">
<?php while ($list = mysql_fetch_assoc($queryresult)): ?>
<div class="category-main-container">
<div class="category-main-desc"> <?php echo $list['title'];?></a>
</div><!--end of category-desc-->
</div><!--end of category-container-->
<?php endwhile;?>
</div>

<div class="TabbedPanelsContent">
<?php while ($list = mysql_fetch_assoc($queryresult)): ?>
<div class="category-main-container">
<div class="category-main-desc"> <?php echo $list['id'];?></a>
</div><!--end of category-desc-->
</div><!--end of category-container-->
<?php endwhile;?>
</div>

<div class="TabbedPanelsContent">
<?php while ($list = mysql_fetch_assoc($queryresult)): ?>
<div class="category-main-container">
<div class="category-main-desc"> <?php echo $list['rating'];?></a>
</div><!--end of category-desc-->
</div><!--end of category-container-->
<?php endwhile;?>
</div>

</div>
</div>
<script type="text/javascript">
var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1");
</script>

而php查询是这样的。

$offset = ($currentpage - 1) * $rowsperpage;
$sqlquery = "SELECT * FROM $tablename ORDER BY $orderby $sortby LIMIT $rowsperpage OFFSET $offset";
$queryresult = mysql_query($sqlquery, $connection) or trigger_error("SQL", E_USER_ERROR);

最佳答案

更简单的方法是为每个选项卡使用单独的 MySQL 查询,如下所示

$sqlquery1 = "SELECT id FROM table_name ORDER BY id ASC";
$queryresult1 = mysql_query($sqlquery1, $connection) or trigger_error("SQL", E_USER_ERROR);
$sqlquery2 = "SELECT title FROM table_name ORDER BY id ASC";
$queryresult2 = mysql_query($sqlquery2, $connection) or trigger_error("SQL", E_USER_ERROR);
$sqlquery3 = "SELECT rating FROM table_name ORDER BY id ASC";
$queryresult3 = mysql_query($sqlquery3, $connection) or trigger_error("SQL", E_USER_ERROR);

在选项卡式菜单中这样做。

<div class="TabbedPanelsContent">
<?php while ($list = mysql_fetch_assoc($queryresult1)): ?>
<div class="category-main-container">
<div class="category-main-desc"> <?php echo $list['id'];?></a>
</div><!--end of category-desc-->
</div><!--end of category-container-->
<?php endwhile;?>
</div>

<div class="TabbedPanelsContent">
<?php while ($list = mysql_fetch_assoc($queryresult2)): ?>
<div class="category-main-container">
<div class="category-main-desc"> <?php echo $list['title'];?></a>
</div><!--end of category-desc-->
</div><!--end of category-container-->
<?php endwhile;?>
</div>

<div class="TabbedPanelsContent">
<?php while ($list = mysql_fetch_assoc($queryresult3)): ?>
<div class="category-main-container">
<div class="category-main-desc"> <?php echo $list['rating'];?></a>
</div><!--end of category-desc-->
</div><!--end of category-container-->
<?php endwhile;?>
</div>

这应该可以解决您的问题。

关于php - Spry 选项卡式面板不显示动态数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10917493/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com