1
我在其他帖子上詢問了這個https://stackoverflow.com/a/14277726/1670630,但我的問題依然存在。 在codeigniter 2.1中,我試圖按類別顯示頻道。所以如果我有一個名爲Film的類別,我應該看到電影中的頻道列表。我嘗試了一個嵌套的foreach循環來實現這一點,但似乎無法讓它在slideshow中工作,並通過行數限制。 我的模型:Codeigniter在幻燈片中嵌套foreach?
<?php
class Pages_model extends CI_Model {
function get_channels_by_categ_tv()
{
$this->db->select('categories.category_name, channels.channel_name');
$this->db->from('type_categ');
$this->db->join('categories', 'categories.category_id = type_categ.category_id');
$this->db->join('channels', 'channels.channel_id = type_categ.channel_id');
$this->db->order_by('categories.category_id');
//$this->db->group_by(array('categories.category_id'));
$query = $this->db->get();
if($query->num_rows() == 0)
{
#no channels
return false;
}
return $query->result_array();
}
}
我有這樣的觀點:
<ul class="slides">
<li>
<?php $cat_shown = ''; ?>
<div class="programe-tv_link">
<?php $cat_show = ''; $cnl_show = '';?>
<?php foreach ($category_chaneels as $category): ?>
<?php
if ($cat_show != $category['category_name']) {
$cat_show = $category['category_name'];
echo '<p>' . $cat_show . '</p>';
}
$cnl_show = $category['channel_name'];
echo '<dd><a href=""> >>' . $cnl_show . '</a></dd> ';
?>
<?php endforeach; ?>
</div>
</li>
<li>
<div class="programe-tv_link">
<p>Arte</p>
<dd> <a href="">>> Acasa</a></dd>
<dd> <a href="">>> Antena 1</a></dd>
<dd> <a href="">>> Pro TV</a></dd>
</div>
<div class="programe-tv_link">
<p>Music Box</p>
<dd> <a href="">>> Acasa</a></dd>
<dd> <a href="">>> Antena 1</a></dd>
<dd> <a href="">>> Pro TV</a></dd>
<dd> <a href="">>> TLC</a></dd>
</div>
</li>
</ul>
我atache與ilustration圖像,
對不起我的英語,如果你不understund我請寫信這裏。 THX提前。
你是指(3頻道/ 1類)? – semsem
嗨semsem。每頁3個類別,但頻道(無限制)。你可以幫我嗎 ? –
這是一個JavaScript問題,不是php或codeigniter問題,它取決於您用於隱藏和顯示幻燈片的方法 – semsem