У меня такой запрос, как
$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 даст мне все данные, необходимые для моего отчета
в
id Report_id title form_id attribute_id
1 1 r1 24 69
2 1 r2 24 72
2. И затем foreach attribute_id, я извлекаю метку Атрибутов из моей таблицы атрибутов во втором запросе $ reportattrid ['Report'] ['attr'];
3.
И затем Foreach Reports attribute_id. Я пытаюсь извлечь записи из моей таблицы результатов, используя $ reportattrid ['Report'] ['value'], которая дает
Сначала, когда 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
Все идет правильно, но теперь
я пытаюсь построить таблицу для отображения в моем представлении
с помощью
<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
как это сделать ?? пожалуйста, предложите мне ...