douzhang6176 2015-03-30 11:19
浏览 62
已采纳

php使用rowspan生成的表

I am using this code to generate a table which will subsequently be modified to upload data to a mysql database.

<?php
$start_loc_number= 1 ;
$start_loc_alpha= 'A' ;
$end_loc_number= 10 ;
$end_loc_alpha= 'J' ;

$out = ''; 

   $out .= '<table border = 1 bordercolor="#FF0000">';

    for($tr='A';$tr<=$end_loc_alpha;$tr++)
    { $out .= "<tr>";
        for($td=1;$td<=$end_loc_number;$td++)
        { $out .= '<td BGCOLOR="#99CCFF">'.$tr.$td.'</td>

                                 <td id="sampleID" contenteditable="true">  sampleID</td>
                                 <td id="volume" contenteditable="true">  volume</td>'  ;
        }
    $out .= "</tr>";
    }

    $out .= "</table>";

echo $out; 
?>

At the moment the table generates 3 cells per iteration in 3 column cells,

| coordinates | sample ID | volume |

My question relates to how the php code can be altered so to generate a table where the coordinates cell can be arranged as a rowspan over the sampleID and volume cells positioned in 2 rows with the sample ID over the volume cell

|             | sample ID
| coordinates |------------
|             | volume
  • 写回答

3条回答 默认 最新

  • donmqryh49993 2015-03-30 11:34
    关注

    try this,

    for($tr='A';$tr<=$end_loc_alpha;$tr++)
        { $out .= "<tr>";
            for($td=1;$td<=$end_loc_number;$td++)
            { $out .= '<td BGCOLOR="#99CCFF">'.$tr.$td.'</td><td>
                                    <table><tr style="border-bottom: 1px solid red">
                                     <td id="sampleID" contenteditable="true">  sampleID</td></tr>
                                    <tr> <td id="volume" contenteditable="true">  volume</td></tr></table></td>'  ;
            }
        $out .= "</tr>";
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配