如何使用PEAR HTML_Table添加rowspan和colspan?

时间:2015-05-27 03:08:44

标签: php html pear

$table->addRow(array("Name","Arrival Time","Departure Time","Amount"),null,"th");

对于Name,我需要2的rowspan和2的colspan for rest。怎么做?使用setCellAttributes()

1 个答案:

答案 0 :(得分:2)

<?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()功能并指定单元格编号