使用多个循环的php html表项

使用多个循环的php html表项,php,html,Php,Html,更新:我一直在尝试用php html编写一个跨表条目,但做不到。对于我表格中的空白主题,我希望显示编辑该单元格的链接 我的更新代码: $days = array("1"=>"Monday", "2"=>"Tuesday", "3"=>"Wednesday", "4"=>"Thursday", "5"=>"Friday", "6"=>"Saturday", "7"=>"Sunday", ); $hours = DB::table('timetablele

更新:我一直在尝试用php html编写一个跨表条目,但做不到。对于我表格中的空白主题,我希望显示编辑该单元格的链接

我的更新代码:

$days = array("1"=>"Monday", "2"=>"Tuesday", "3"=>"Wednesday", "4"=>"Thursday", "5"=>"Friday", "6"=>"Saturday", "7"=>"Sunday", );

$hours = DB::table('timetablelectures')->select('timetablelectures.id', 'timetablelectures.start_time')
                                ->get();
$timetable = DB::table('timetable')->select('timetable.id', 'timetable.day', 'timetable.lecture_id', 'timetable.subject_id')
                                ->get();
//制定时间表

$schedule = array();

    foreach($timetable as $tt) 
        {
        foreach($days as $x => $x_value) 
            {
                if ( $tt->day==$x)
                            {
                            $schedule["{$x}"][$tt->lecture_id][] = $tt->subject_id;
                            }
            }
        }


// DISPLAY SCHEDULE, headers first
?>

<table border="1">
    <tr><td align="center">Time</td>
 <?php foreach ( $hours as $hour ) 
                {
                    echo "<td>  $hour->start_time </td>";
                }
                echo "</tr>";

foreach ( $days as $x => $x_value) {
    echo "<tr><td>$x_value</td>";

    // roll through days
    foreach ( $hours as $hour ) {
        echo '<td>';
        // check for subjects in this slot
        if ( isset($schedule[$x][$hour->id]) ) {
            // and display each
            foreach ( $schedule[$x][$hour->id] as $subject ) {
                echo "$subject<br>";
            }
        }
        echo '</td>';
    }
    echo '</tr>';
}
echo '</table>';
$schedule=array();
foreach(时间表为$tt)
{
foreach($x=>$x_值的天数)
{
如果($tt->day==$x)
{
$schedule[“{$x}”[$tt->teachment\u id][]=$tt->subject\u id;
}
}
}
//显示明细表,首先显示标题
?>
时间

你能添加你得到的输出吗?你能添加包含数据的数组来填充表格吗