我有包表:
+----+--------------+
| id | package_name |
+----+--------------+
| 1 | simple |
| 2 | elegant |
+----+--------------+
以及宣传册表:
+----+------------+-------------+
| id | package_id | image |
+----+------------+-------------+
| 1 | 1 | simple.jpg |
| 2 | 2 | elegant.jpg |
+----+------------+-------------+
然后我将包表记录循环到生成的标签列表中,如下所示:
<div class="tabbable tabs-left">
<ul class="nav nav-tabs">
<li class="active">
<a href="#package_1" data-toggle="tab">
Simple
</a>
</li>
<li class="">
<a href="#package_2" data-toggle="tab">
Elegant
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="package_1">
<div class="col-xs-3" id="package-detail">
</div>
<div class="col-xs-7" id="brochure_1">
<!-- SHOW BROCHURE IMAGE BY PACKAGE ID HERE -->
<!-- END -->
</div>
</div>
<div class="tab-pane " id="package_2">
<div class="col-xs-3" id="package-detail">
</div>
<div class="col-xs-7" id="brochure_2">
<!-- SHOW BROCHURE IMAGE BY PACKAGE ID HERE -->
<!-- END -->
</div>
</div>
</div>
</div>
我希望根据 id 从宣传册表中显示 图片 由选定的标签列表触发的包表,并将图片放在此标记之间:
<div class="col-xs-7" id="brochure_2">
<!-- SHOW BROCHURE IMAGE BY PACKAGE ID HERE -->
<!-- END -->
</div>
这是我的控制器
$this->load->model('admin/package_model', 'package');
// SELECT ALL DATA FROM PACKAGE TABLE
$this->data['packages'] = $this->package->get();
$this->load->model('admin/brochure_model', 'brochure');
// GET DATA FROM BROCHURE TABLE WHERE PACKAGE_ID = ID (FROM PACKAGE TABLE FROM SELECTED TAB)
$this->data['brochures'] = $this->brochure->get_by(array(
'package_id' => ID VARIABEL FROM SELECTED TABS'
));
$this->load->view('frontend/page/package', $this->data);
谢谢你