2012-06-06 54 views
0

您好我正在嘗試使用動態數據設置spry選項卡式面板,我想使用單個查詢來完成這項工作,我只在「選項卡1」,「選項卡2」 ,「Tab 3」沒有顯示任何數據,我想我使用while循環來重複區域三次使用相同的查詢,這就是爲什麼發生這種情況,我嘗試使用foreach循環但沒有幫助,這是我迄今爲止的測試代碼,請建議什麼是正確的方法來做到這一點。Spry選項卡式面板不顯示動態數據

謝謝。

我的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); 

回答

1

簡單的方法來做到這一點是通過使用單獨的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> 

這應該解決您的問題。

+0

謝謝,它的工作方式。 –

相關問題