j'ai une requête commeStructurer un tableau avec les résultats de 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.Le première pour volonté $ report_attrid me donne les toutes les données nécessaires à mon rapport
comme
id Report_id title form_id attribute_id
1 1 r1 24 69
2 1 r2 24 72
2.Et puis pour chaque attribut, je récupère l'étiquette Attributs de ma table attributaire dans la deuxième requête $ reportattrid ['Report'] ['attr'];
3. Et puis Foreach rapports attribute_id je suis en train de chercher les entrées de ma table de résultats en utilisant $ reportattrid [ 'Report'] [ 'value'] qui donne comme
Au début, quand attribute_id = 69 il renvoie 2 rangs
que
id form_id attribute_id value
1 24 69 A
2 24 69 B
Puis attribute_id = 72 il renvoie 2 rangs
comme
id form_id attribute_id value
3 24 72 C
4 24 69 D
Tout retriving correctement mais maintenant
je suis en train de construire une table pour afficher à mon avis
utilisant
<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>
qui me affiche comme
Firstname experience
A B
C D
mais je besoin de la table
Firstname experience
A C
B D
comment faire ?? S'il vous plaît me suggérer ...