At last I managed to sort the issue.... This is my code
Action.php
`
$recdata = $sql->showuploadedrecords($evntid);
$coldata =$sql->showuploadedcols($evntid);
$colmns = array();
foreach ($coldata as $ky => $valu) {
$colname = $valu['column_name'];
$colmns[] = $colname;
}
$records = array();
$total = count($recdata)/count($colmns);
for ($i = 1; $i < $total +1; $i++) {
$one =array();
foreach ($recdata as $k => $v) {
if($v['relate_records']==$i){
$one[]=$v;
}
}
$records[] = $one;
}
$this->render('ViewUploaded', array('colmns' => $colmns,
'data' => $records));
}`
And on my View:
`echo '<tr role="row">';
foreach ($colmns as $value) {
echo '<th class="sorting_asc" role="columnheader" tabindex="0" aria-controls="DataTables_Table_2" rowspan="1" colspan="1" style="width: 219px;" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending">'. $value . '</th>';
}
echo '</tr>';
?>
</thead>
<?php
foreach ($data as $key => $v) {
echo '<tr>';
for ($k = 0; $k < count($colmns); $k++) {
foreach ($v as $cell) {
if($cell['column_name']== $colmns[$k]){
echo'<td>'.$cell['item'].'</td>';
}
}
}
echo '</tr>';
}
?>
</tbody>
</table>`