简体   繁体   English

如何将数据显示为html表?

[英]How to display Data as html table?

I am trying to display tabular data from my database. 我试图从我的数据库中显示tabular数据。 I have the following data to display: 我要显示以下数据:

title              name                job                      email
manager            Jeff               _____                     _____
developer          Jerry           develop web              jer@test.com    
_____               Harry               IT                      ______

The director will enter the blank field in my table in my webpage. 导演将在我的网页中输入我的表格中的空白字段。

The data is stored in the database as a single text column. 数据作为单个文本列存储在数据库中。 As far as best practices go, should I be storing this data in the database as pre-generated HTML or as a delimited string? 就最佳实践而言,我应该将这些数据作为预生成的HTML或分隔的字符串存储在数据库中吗?

In my experience, it's always better to keep the data stored just as data, and keep all "view" logic elsewhere. 根据我的经验,最好将数据保存为数据,并将所有“视图”逻辑保留在其他地方。 Storing the data as HTML can also cause (a multitude of) problems later such as, if you decide to add a web service. 将数据存储为HTML也可能导致(大量)问题,例如,如果您决定添加Web服务。

Update: I read your comment above - even if you only have one column to store your data in, you can serialize a data structure and store it there. 更新:我在上面阅读了您的评论 - 即使您只有一列来存储数据,您也可以serialize数据结构并将其存储在那里。

see: php.net serialize() doc 请参阅: php.net serialize()doc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM