【问题标题】:How to add rowspan and colspan using PEAR HTML_Table?如何使用 PEAR HTML_Table 添加行跨度和列跨度?
【发布时间】:2015-05-27 21:03:32
【问题描述】:
$table->addRow(array("Name","Arrival Time","Departure Time","Amount"),null,"th");

我需要 2 的行跨度作为名称和 2 的列跨度作为休息。怎么做?使用setCellAttributes()?

【问题讨论】:

    标签: php html pear


    【解决方案1】:
    <?php
    require_once("HTML/Table.php");
    $attr = array("style" => "border:1px solid black;text-align:center;width:500px;height:100px;","align" => "center","border"=>1,"cellspacing"=>"0","cellpadding"=>"5");
    $table = new HTML_Table($attr);
    $table->addRow(array("Name", "Arrival Time","","Departure Time","", "Amount"),null, "th");
    $table->addRow(array("", "AM","PM","AM","PM","Rupees","Paisa"), null,"th");
    $table->setCellAttributes(0,0,"rowspan='2'");
    for($i=1;$i<=5;$i++){
        $table->setCellAttributes(0,$i,"colspan='2'");
    }
    $table->addRow(array("Toyota","4","","","6","80","50"),null);
    $table->addRow(array("Toyota","","8","2","","180","30"),null);
    echo $table->toHTML();
    ?>
    

    您需要使用setCellAttributes()函数并指定单元格编号

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-06
      • 2020-07-23
      • 1970-01-01
      • 2019-11-26
      • 1970-01-01
      • 2014-07-27
      • 2012-10-24
      • 1970-01-01
      相关资源
      最近更新 更多