Php 如何根据时间表中的特定日期和时段显示主题和房间名称?
我从周一到周六有6天的时间。但我在数据库中只存储了3天的周期。Php 如何根据时间表中的特定日期和时段显示主题和房间名称?,php,cakephp,Php,Cakephp,我从周一到周六有6天的时间。但我在数据库中只存储了3天的周期。 我在阵列中得到了这些东西,就像这样 Array ( [0] => Array ( [subject] => 17 [room] => 3 [period] => 1 [day] => 1 ) [1] => Array (
我在阵列中得到了这些东西,就像这样
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();?>
1。
您能否添加所需结果的示例?请在您的问题中添加有关您的要求的更多信息。您的需求可以转化为简单的if/else、while等语句,但前提是您以更清晰的方式进行解释。给我们看看你想要的产量。您想要显示的内容的示例。我正在为一个班级设计时间表。从星期一到星期六。我六天里只有一次月经。但各个时期的主题都不同。我想在相应的日期显示相应时段内的主题。上面显示的数组是我从控制器获得的输出。如何将这些id更改为名称并显示在视图中???不,不要在评论中解释,请单击链接。我们想要的是你告诉我们“我想要的输出是PeriodSubjectScience1…
当然这只是一个例子。请用静态HTML向我们展示你想要的输出。