td rowpans添加到表?
it1352
帮助1人
问题说明
我在想一种使td rowpans具有相同项目的方法吗?..我的意思是
I was thinking of a way to make td rowspans with the same items?.. I mean
请看下表,这是输出的样子,只是一个例子.
look at this table below, this how the output looks like, just an example.
如何使输出看起来像这样,所以处理起来会很容易.
how can I make the output look like this, so handling things will be easy..
在这里编码
$get = file_get_contents('URL');
$json = json_decode($get, true);
$items = $json['Catalogue'][0]['Accessories'];
$quantity = $json['Accessories'][1]['Quantity'];
$price = $json['Accessories'][2]['Price'];
echo
"<table border=1>
<tr>
<th width=200px>Items</th>
<th width=100px>Quantity</th>
<th width=100px>Price</th>
</tr>
<tr>
<td>".$items."</td>
<td>".$quantity."</td>
<td>".$price."</td>
</tr>
</table>";
正确答案
#1
您可以使用rowspan创建所需的表.参见下面的演示.
You could use rowspan to create the desired table you like. See below demo.
您需要注意的两件事,
- 将
rowspan="N"
添加到要显示TD
的起始行. N是要合并的行数 - 在下一个
N
行中不包括TD
.合并的行应该只有一个TD
,并且TD
应该具有rowspan
.
- Add
rowspan="N"
to the starting row where you going to show theTD
. N is number of rows to merge - Don't include
TD
for the nextN
row. There should be only oneTD
for the merged row and thatTD
should have therowspan
.
呈现表时,您需要在迭代过程中注意上述2条规则.
You need to take care of the above 2 rules in your iterate when rendering the table.
td, th { text-align: center; }
<table border="1">
<tr>
<th style="width:200px">Items</th>
<th style="width:100px">Quantity</th>
<th style="width:100px">Price</th>
</tr>
<tr>
<td rowspan="3">Sports Watch</td>
<td>1</td>
<td>$89.99</td>
</tr>
<tr>
<td>2</td>
<td>$179.98</td>
</tr>
<tr>
<td>3</td>
<td>$267.97</td>
</tr>
<tr>
<td rowspan="2" style="text-align: center;">Portable Digital Camera</td>
<td>1</td>
<td>$196.99</td>
</tr>
<tr>
<td>2</td>
<td>$393.98</td>
</tr>
</table>
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfhgfg
系列文章
更多
同类精品
更多
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20