无法使用php

时间:2017-03-01 14:42:22

标签: php html html-table

我正在尝试使用表格显示预订,这些表格包含动态行和行数。

这是我的代码:

    <table border="1" style='width: 100%' >
        <tr>
            <th style='background-color:green;width: 80px' ><font color="white">Time</font></th>
            <?php
                $i=1;
                while($i<=$no_court)
                {
                    echo "<th  style='background-color:green;width: 80px'> <font color='white'>Court".$i."</font></th>";
                    $i+=1;
                }
            ?>
        </tr>
        <tr>
            <td>8:00 AM</td>
            <?php
                $i=1;
                while($i<=$no_court)
                {
                    $flag=0;
                    $j=0;
                    while(sizeof($start) > $j )
                    {
                        $start_time=$start[$j];
                        $finish_time=$finish[$j];
                        $court=$court1[$j];
                        $sst = strtotime($start_time);
                        $eet=  strtotime($finish_time);
                        $diff= $eet-$sst;
                        $timeElapsed= gmdate("h:i",$diff);
                        $timeElapsed+=1;
                        if ($start_time=='08:00:00' && $court==$i)
                        {
                            $fio_time=$finish[$j];
                            if($fio_time=='13:00:00')
                            {
                                $f_time='1:00:00';
                            }

                            $f=$facility_id[$j];
                            $sql15 = $dbConnection->prepare('SELECT * FROM tbl_facility WHERE facility_id=?');
                            $sql15->execute(array($f));
                            $row15 = $sql15->fetch();

                            $facility_name=$row15['facility_name'];
                            if($block_by[$j]=="1")
                            {                                               
                                echo "<td style='background-color:blue;' rowspan='$timeElapsed'>
                                <font size='2' color='white'><b><center>$league[$j]</b></br>
                                Reserved </br>
                                $facility_name</br>
                                $start_time-$f_time</br>
                                <a href='' onClick='javascript: openPopup($id[$j])' style='color:white;'>Edit</a>
                                <a href='delete.php?id=$id[$j]' style='color:white;' onclick='return confirmdelete()' >Delete</a>
                                </center></font></td>";
                                break;
                            }
                            elseif($block_by[$j]=="2")
                            {
                                $p=$player_id[$j];
                                $sql17 = $dbConnection->prepare('SELECT * FROM tbl_player_registration WHERE player_id=?');
                                $sql17->execute(array($p));
                                $row17 = $sql17->fetch();
                                $first_name=$row17['first_name'];   
                                echo "<td style='background-color:gray;' rowspan='$timeElapsed'>
                                <font size='2' color='white'><b><center>Reserved By</b></br>
                                $first_name </br>
                                </center></font></td>";
                                break;
                            }
                        }
                        elseif($start_time <='08:00:00' && $finish_time >='08:00:00' && $court==$i )
                        {
                            break;
                        }
                        elseif($court==$i )
                        {
                            $l=0;
                            while(sizeof($court) > $l)
                            {
                                $ta=$start[$l];
                                $fa=$finish[$l];
                                $ca=$court1[$l];
                                if($ta >='08:00:00' && $fa <='08:00:00' && $ca==$i )
                                {
                                    $flag=1;$court=$ca;
                                }
                                $l+=1;
                            }
                        }
                        $j+=1;
                    }
                    if($flag==1 )
                    {
                        echo "<td></td>";
                    }
                    if($flag==0 )
                    {

                    }
                    if($court != $i)
                    {
                        echo "<td></td>";
                    }
                    $i+=1;
                }
            ?>
        </tr>
    </table>

显示输出为此图像:

它正确显示数据,但添加了一个额外的列,这使得表格看起来令人不安。

我想将结果显示为此图片:

我在弄乱代码的地方有点困惑。请帮助解决这个问题。

0 个答案:

没有答案