0
我有像构建与CakePHP的
$report_attrid=$this->Report->find('all',array('conditions'=>array('Report.report_id'=>$report_id,'Report.user_id'=>$userId)));
foreach($report_attrid as & $reportattrid):
$reportattrid['Report']['attr']=$this->Attribute->find('all',array('fields'=>array('Attribute.id','Attribute.label'),'conditions'=>array('Attribute.id'=>$reportattrid['Report']['attribute_id'],'Attribute.form_id'=>$report_form_id),'order'=>'Attribute.sequence_no'));
$reportattrid['Report']['value']=$this->Result->find('all',array('fields'=>array('Result.label','Result.value','Result.submitter_id','Result.submitter'),'conditions'=>array('Result.attribute_id'=>$reportattrid['Report']['attribute_id'],'Result.form_id'=>$report_form_id),'order'=>'Result.id'));
endforeach;
$this->set('Report_attrid',$report_attrid);
1.第一个为$ report_attrid将查询结果的表给我的一切需要我的报告DATAS
为
id Report_id title form_id attribute_id
1 1 r1 24 69
2 1 r2 24 72
2.And随后的foreach attribute_id,我从我的属性表中的第二个查询$ reportattrid [ '报告'] [ 'ATTR']获取属性标签;
3. 然后的foreach报告attribute_id我试图使用$ reportattrid [“报告”] [“值”]这给作为
首先,从我的成绩表中提取的条目时attribute_id = 69它返回2行
作为
id form_id attribute_id value
1 24 69 A
2 24 69 B
然后attribute_id = 72返回2行
如
id form_id attribute_id value
3 24 72 C
4 24 69 D
一切retriving正确的,但现在
我想建立一个表,可以使用在我看来
显示
<table id="sampletable">
<thead>
<?php foreach ($Report_attrid as $report1): ?>
<th id="headerid<?php echo $report1['Report']['attr'][0]['Attribute']['id'];?>"><?php echo $report1['Report']['attr'][0]['Attribute']['label'];?>
</th>
<?php endforeach; ?>
<?php foreach ($Report_attrid as $report2): ?>
<tr> <?php foreach ($report2['Report']['value'] as $report3): ?>
<td> <?php echo $report3['Result']['value'];?> </td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</table>
它显示我像
Firstname experience
A B
C D
,但我需要的表作为
Firstname experience
A C
B D
怎么做?请建议我...