Hi,
i am having a query like
$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.the first one for $report_attrid will gives me the all the datas needed for my report
as
id Report_id title form_id attribute_id
1 1 r1 24 69
2 1 r2 24 72
2.And then foreach attribute_id , i am fetching the Attributes label from my attribute table in the second query $reportattrid;
3.
And then Foreach Reports attribute_id i am trying to fetch the entries from my results table using $reportattrid which gives as
At first when attribute_id = 69 it returns 2 rows
as
id form_id attribute_id value
1 24 69 A
2 24 69 B
Then attribute_id = 72 it returns 2 rows
as
id form_id attribute_id value
3 24 72 C
4 24 69 D
Everything retriving correctly but now
i am trying to build a table to display in my view
using
<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; ?>
</thead>
<tbody>
<?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; ?>
</tbody>
</table>
which displays me like
Firstname experience
A B
C D
but i need the table as
Firstname experience
A C
B D
how to do so?? please suggest me...