读从MySQL数据库中的数据到一个HTML表?数据库中、数据、MySQL、HTML

2023-09-10 21:43:40 作者:我想稳定

所以我工作的一个项目,需要一些建议。

So i am working on a project and need some advice.

我有一个存储事件MySQL数据库,我知道如何code这个功能在PHP,但我只是坚持的一些细节。

I have a MySQL database that stores events, i know how to code this functionality in PHP but im just stuck of a few specifics.

正如我正在创建项目是一个时间表,最重要的属性是该事件的天,开始时间和结束时间。

As the project that I am creating is a timetable, the most important attributes are the day of the event, starting time and finishing time.

在我读从MySQL数据库使用我的PHP脚本这个数据,我怎么去到一个HTML时间表插入这些事件?

Once i have read this data from the MYSQL database using my PHP script, how do i go about inserting these events in to a html timetable?

可以说我有类似的记录下面我事件表:

Lets say i have record like below in my events table:

事件ID = 01 活动日=星期一 活动开始= 12:00 活动结束= 14:00

Event ID = 01 Event Day = Monday Event Start = 12:00 Event End = 14:00

我怎么然后将其写入一个HTML表,同时考虑到我可能多发事件的一天?

How would I then put that into a html table, bearing in mind that i may have mutiple events for a day?

推荐答案

您可以从PHP搭配你的结果转换成HTML code:

You can mix your result from PHP into HTML code:

<table>
<?php
foreach ($results as result){
  echo '<tr><td>'.$result->field.'</td></tr>';
}
?>
</table>