如何设计html时间表

发布于 2024-09-03 00:25:41 字数 2667 浏览 2 评论 0原文

我目前正在开展一个项目,需要打印课程时间表。这是我创建的链接 http://conorhackett.com/tt/

它现在工作正常,但我想对其有更多的控制权。如果您查看代码,您就会明白我的意思。 html/css 非常混乱。

我尝试过使用 html 表格来完成此操作,但所有行看起来都不太好。

有没有什么基础可供我用作基础?

任何adive都非常感激:)

--Conor

更新:

大家好,

我决定回到html表。我很难理解用于打印数据的逻辑。

这是我打印表格的代码:

        foreach($bookingList->result_array() as $row)
    {

        $time   = $row['start_time']. ' - ' .$row['end_time'];
        $lesson = $row['lesson_type_name'];
        $client = $row['client_firstname']. ' ' .$row['client_lastname'];
        $horse  = $row['horse_name'];
        $fee    = $row['fee'];


        if(empty($prevLesson) && empty($prevTime))
        {
            echo '1';
            $timeArr    .= $time;
            $lessonArr  .= $lesson;
            $clientArr  .= $client;
            $horseArr   .= $horse;
            $feeArr     .= $fee.'-'.$i;


        }
        elseif($prevLesson == $lesson && $prevTime == $time)
        {               

            echo '3';
            echo '<br/>Previous: '.$prevTime.'++'.$prevLesson.'-'.$i.'<br/>';
            echo '<br/>Current: '.$time.'++'.$lesson.'-'.$i.'<br/>';

            $timeArr    .= $time;
            $lessonArr  .= $lesson;
            $clientArr  .= $client;
            $horseArr   .= $horse;
            $feeArr     .= $fee.'-'.$i;







        }
        else
        {


            echo '3';

            echo '<tr>';

            echo '<td>(3)'. $timeArr .'</td>';
            echo '<td>'. $lessonArr .'</td>';
            echo '<td>'. $clientArr .'</td>';
            echo '<td>'. $horseArr .'</td>';
            echo '<td>'. $feeArr.'</td>';
            echo '<td>'. $i.'</td>';

            echo '</tr>';

            $timeArr = ' ';
            $lessonArr = ' ';
            $clientArr = ' ';
            $horseArr = ' ';
            $feeArr = ' ';
            $optionsArr = ' ';

            $timeArr    .= $time.'<br/>';
            $lessonArr  .= $lesson.'<br/>';
            $clientArr  .= $client.'<br/>';
            $horseArr   .= $horse.'<br/>';
            $feeArr     .= $fee.'-'.$i.'<br/>'; 






        }
        $prevTime = $time;
        $prevLesson =  $lesson;
        $i += 1;
    }

打印的想法是: 从数据库中读取数据并存储在字符串中。当数据更改(时间和课程类型)时,打印存储的字符串,清除它并将新的(不同的数据)分配给打印字符串。

我已经按原样放置了代码..我现在感到非常沮丧和疲倦。这周我每天晚上都花了 3 个小时试图完成,但每次都失败了。如果你愿意帮助我并且需要更详细的信息,现在就让我知道。

非常感谢任何帮助。 谢谢。

I'm currently working on a project where I need to print out a lesson timetable. Here is a link to the one I have created http://conorhackett.com/tt/.

It works fine now but i'd like to have more control over it. If you look at the code you'll see what I mean. The html/css is very messy.

I've tried to do it with a html table but it didn't look great with all the lines.

Is there any foundations available to me that I could use as a base.?

Any adive greatly appreciated :)

--Conor

Update:

Hi Guys,

I've decided to go back to a html table. I am having extreme difficulty getting my head around the logic used to print the data.

Here is my code for printing the table:

        foreach($bookingList->result_array() as $row)
    {

        $time   = $row['start_time']. ' - ' .$row['end_time'];
        $lesson = $row['lesson_type_name'];
        $client = $row['client_firstname']. ' ' .$row['client_lastname'];
        $horse  = $row['horse_name'];
        $fee    = $row['fee'];


        if(empty($prevLesson) && empty($prevTime))
        {
            echo '1';
            $timeArr    .= $time;
            $lessonArr  .= $lesson;
            $clientArr  .= $client;
            $horseArr   .= $horse;
            $feeArr     .= $fee.'-'.$i;


        }
        elseif($prevLesson == $lesson && $prevTime == $time)
        {               

            echo '3';
            echo '<br/>Previous: '.$prevTime.'++'.$prevLesson.'-'.$i.'<br/>';
            echo '<br/>Current: '.$time.'++'.$lesson.'-'.$i.'<br/>';

            $timeArr    .= $time;
            $lessonArr  .= $lesson;
            $clientArr  .= $client;
            $horseArr   .= $horse;
            $feeArr     .= $fee.'-'.$i;







        }
        else
        {


            echo '3';

            echo '<tr>';

            echo '<td>(3)'. $timeArr .'</td>';
            echo '<td>'. $lessonArr .'</td>';
            echo '<td>'. $clientArr .'</td>';
            echo '<td>'. $horseArr .'</td>';
            echo '<td>'. $feeArr.'</td>';
            echo '<td>'. $i.'</td>';

            echo '</tr>';

            $timeArr = ' ';
            $lessonArr = ' ';
            $clientArr = ' ';
            $horseArr = ' ';
            $feeArr = ' ';
            $optionsArr = ' ';

            $timeArr    .= $time.'<br/>';
            $lessonArr  .= $lesson.'<br/>';
            $clientArr  .= $client.'<br/>';
            $horseArr   .= $horse.'<br/>';
            $feeArr     .= $fee.'-'.$i.'<br/>'; 






        }
        $prevTime = $time;
        $prevLesson =  $lesson;
        $i += 1;
    }

The idea for printing is:
Read data from DB and store in a string. when the data changes (time and lesson type) print the stored string, clear it and assign the new (different data) to the print string.

I have put up the code as is.. i'm just so frustrated and tired now. I have spent 3 hourse every evening this week trying to complete and have failed every time.. If you are willing to help me and need more detailed just let me now..

Any help really appreciated..
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我们只是彼此的过ke 2024-09-10 00:25:48

Soln: foreach 循环完成后,打印字符串中仍然有数据。我只是在 foreach 循环之后回应这一点,它解决了所有问题。感谢大家的帮助输入。

Soln: After the foreach loop had finished I still had data in the print string. I just echo that after the foreach loop and it solved everything. Thanks for the help input guys.

偏爱自由 2024-09-10 00:25:46

除了 Amadan 的建议之外,还可以考虑使用 colspanrowspan 来使每个框占据所需的空间。查看这些的源代码示例 看看我的意思。

In addition to Amadan's suggestion, consider using colspan and rowspan to make each box take up the space required. Review the source code on these examples to see what I mean.

一杆小烟枪 2024-09-10 00:25:45

使用以下命令再次尝试表:

table {
    border-collapse: collapse;
}

Give tables another shot, using this:

table {
    border-collapse: collapse;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文