I have 6 days from monday to saturday. But I have stored only 3 days periods in database.
I got those things in the array like this.
Array
(
[0] => Array
(
[subject] => 17
[room] => 3
[period] => 1
[day] => 1
)
[1] => Array
(
[subject] => 8
[room] => 2
[period] => 1
[day] => 3
)
[2] => Array
(
[subject] => 10
[room] => 1
[period] => 1
[day] => 5
)
.....
Now I need to display this in the view. If I have subject in the particular period, I want to display that, else all subjects should display.
my ctp file content:
1. <table id="ss" style="border:1px solid #cccccc" class="form_text">
<tr style="background: url('<?php echo $this->webroot;?>img/title.gif') repeat-x; height:20px">
<td align="center" style="width:1%"><strong>Days</strong></td>
<?php foreach($period_num as $k) : ?>
<td align="center" style="width:2%"><strong><?php echo $k ?></strong></td>
<?php endforeach ?>
</tr>
<?php for($i=0; $i<6; $i++) : ?> <?php
if ( ( $i % 2) == 0 )
$bg_color = "#efefef";
else
$bg_color = "#FFF"; ?> <tr style="background: <?php echo $bg_color; ?>"> <?php
$total=count($period_num);?> <?php for($j=0; $j<=$total; $j++) :
?> <?php $index = $i*$total+$j-1 ?>
<?php $count=0; ?>
<td> <?php if($j==0) : ?>
<?php echo $workingDays[$i]['Day']['day_name'] ?>
<?php elseif($j!=0 && $subject==0): ?>
<?php echo $form->hidden('ClassSchedule.'.$index.'.day_id',
array('value'=>$workingDays[$i]['Day']['day_id'],
'style' => 'width: 35%;'));?>
<?php echo $form->hidden('ClassSchedule.'.$index.'.period_name',
array('value'=>$j,
'style' => 'width: 35%;'));
?>
<?php echo $form->input('ClassSchedule.'.$index.'.subject_id', array('options'=>$subject_sel,'empty'=>'none')) ?>
<?php echo $form->input('ClassSchedule.'.$index.'.room_id', array('options'=>$room_sel,'empty'=>'none')) ?>
<?php else:?>
<?php echo $form->hidden('ClassSchedule.'.$index.'.day_id',
array('value'=>$workingDays[$i]['Day']['day_id'],
'style' => 'width: 35%;'));?>
<?php echo $form->hidden('ClassSchedule.'.$index.'.period_name',
array('value'=>$j,
'style' => 'width: 35%;')); ?>
<?php echo $form->input('ClassSchedule.'.$index.'.subject_id',
array('options'=>$subject_sel)) ?>
<?php echo $form->input('ClassSchedule.'.$index.'.room_id', array('options'=>$room_sel)) ?> <?php endif ?>
<?php endfor ?> </td> <?php $count++; ?> </tr> <?php endfor ?> </table> <?php } ?>
<?php echo $form->end();?>