读从MySQL数据库中的数据到一个HTML表? [英] Reading data from a MySQL database into a HTML Table?

查看:288
本文介绍了读从MySQL数据库中的数据到一个HTML表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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>

这篇关于读从MySQL数据库中的数据到一个HTML表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆