php创建动态html表
我需要在解析 JSON 文件后使用 PHP 创建一个动态 html 表。
我的表需要这个列结构; 姓名 |状态 |年龄 |计数 |进展|不好
如何为从 JSON 文件解析的每个“记录”创建一个新行(我可以创建一个制表符分隔的字符串)。
另一个困难是某些“记录”仅包含该列的数据所有列的“名称”和其他内容。
所以我的问题是如何动态添加一行到表中并填充右列?
(JSON 文件的关键是列标题)
JSON 格式示例:
{
"John": {"status":"Wait" },
"Jennifer": {"status":"Active" },
"James": {"status":"Active","age":56,"count":10,"progress":0.0029857,"bad":0}
}
I need to create a dynamic html table using PHP after parsing a JSON file.
I need this column structure for my table; Name | Status | Age | Count | Progress | Bad
How can I create a new row for every 'record' parsed from the JSON file (I can create a tab separated string).
An additional difficulty is that some 'records' only contain data for the column 'Name' and others for all columns.
So my question is how to add a row dynamically to the table and fill the right column ?
(The key form the JSON file is the column header)
Example of JSON format:
{
"John": {"status":"Wait" },
"Jennifer": {"status":"Active" },
"James": {"status":"Active","age":56,"count":10,"progress":0.0029857,"bad":0}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的事情会起作用:
Something like this would work: