doutingyou2198 2012-04-09 19:16
浏览 43
已采纳

表rowspan问题

I have the following table. The header is at it looks and the content is generated within a PHP loop. It contains some taxes that a user has to pay and a tax can be paid in installments. For example, if the user has to pay a 100$ tax and he first pays 25$ and then 75$, there will be two rows in the table for that tax.

What I seem to fail to accomplish is to make a rowspan so the tax name will be displayed only once.

Any help is appreciated.

<table cellpadding="0" cellspacing="0" width="100%" class="sortable">
    <thead>
        <tr>                                                        
            <th width="10%">Tax name</th>
            <th width="10%">Value</th>
            <th width="10%">Paid</th>
            <th width="10%">Rest</th>            
        </tr>
    </thead>
    <tbody>
        <tr>                                    
            <td>Sign-up tax</td>
            <td>100$</td>
            <td>25$</td>
            <td>75$</td>                        
        </tr>   
        <tr>                                    
            <td>Sign-up tax</td>
            <td>100$</td>
            <td>75$</td>
            <td>0$</td>                        
        </tr>
    </tbody>
</table>

The PHP code looks like this:

<?php for ($i = 0; $i < count($tax_details); $i++): ?>
<tr>                                    
    <td><?php echo $tax_details[$i]['name']; ?></td>
    <td><?php echo $tax_details[$i]['value']; ?></td>
    <td><?php echo $tax_details[$i]['paid']; ?></td>
    <td><?php echo $tax_details[$i]['rest']; ?></td>                        
</tr>
<?php endfor; ?>
  • 写回答

2条回答 默认 最新

  • donglian8407 2012-04-09 19:18
    关注

    replace the html with this:

    <tbody>
        <tr>                                    
            <td rowspan="2">Sign-up tax</td>   <---add rowspan here
            <td>100$</td>
            <td>25$</td>
            <td>75$</td>                        
        </tr>   
        <tr>                                    
            <td>100$</td>         <---remove second sign-up tax from here
            <td>75$</td>
            <td>0$</td>                        
        </tr>
    </tbody>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘