简体   繁体   中英

How to display Data as html table?

I am trying to display tabular data from my database. 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?

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.

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.

see: php.net serialize() doc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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