我正在尝试在主要磁贴下安排一些字幕,但它正在重复标题。
<div id="downloads" class="tab-pane" role="tabpanel">
<?php
$product_id = $model->id;
$downloads_model = Printingmachinedownloads::find()->where(['productid'=>$product_id])->all();
foreach ($downloads_model as $doc) {
$doc_type = $doc['type'];
$doc_label = $doc['documentlabel'];
$doc_title = $doc['documentname'];
?>
<div class="amazingcarousel-container-1 tab_style">
<h3><?php echo $doc_type;?></h3>
<a target = '_blank' href="<?php echo Yii::$app->homeUrl?>images/printingmachine/downloads/<?php echo $doc_title; ?>">
<?php echo $doc_label ?>
</a>
</div>
<?php
}
// $doc_title = $downloads_model[0]->documentlabel;
?>
</div>
</div>
输出结果为:
我需要的是
Brochures
abc
def
ghi
Specificationsheet
xyz
lmn
opq
有人可以告诉我我该做什么吗?
先谢谢
答案 0 :(得分:0)
如果您没有按概念遇到新MySQL版本组的问题,可以使用以下内容:
function rowdoubleclick(e) {
var tablerow = $(e).closest('tr');
var rowammend = $('.lastcolumn');
var matching = $(e).closest('tr').next('tr.matching');
if(matching.is(":hidden")) {
tablerow.attr('rowspan','2').css({'border-bottom':'transparent'});
matching.slideToggle("fast");
rowammend.attr('rowspan','2');
}
else {
tablerow.css({'border-bottom':'1px solid #939393'});
matching.hide();
rowammend.attr('rowspan','1');
}
}
如果您对小组有问题可以使用很少的非标准方式,那么这不是最佳实践和有效方式:
...
$downloads_model = Printingmachinedownloads::find()->where(['productid'=>$product_id])->groupBy(['type'])->all();
foreach($downloads_model as $doc):
<div class="amazingcarousel-container-1 tab_style">
<h3><?= type['type'] ?></h3>
$subtitles = Printingmachinedownloads::find()->where(['productid'=>$product_id, 'type' => $doc['type'] )->all();
foreach($subtitles as $subtitle):
<a target = '_blank' href="<?php echo Yii::$app->homeUrl?>images/printingmachine/downloads/<?php echo $subtitle['documentname']; ?>">
<?php echo $subtitle['documentlabel'] ?>
</a>
enforeach;
</div>
endforeach;
...
我没有测试它,但类似的东西应该工作。 但我的建议和有效的方法是使用关系表1标题容器另一个包含子标题的相关表。