从星期一到星期六我有6天。但我在数据库中只存储了3天的时间 我在这个数组中得到了这些东西。
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
)
.....
现在我需要在视图中显示它。如果我在特定时期有主题,我想显示,否则应显示所有主题。
我的ctp文件内容:
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();?>