简体   繁体   中英

How to add rowspan and colspan using PEAR HTML_Table?

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

I need rowspan of 2 for Name and colspan of 2 for rest. How to do that? use setCellAttributes() ?

<?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();
?>

You need to use setCellAttributes() function and specify the cell number

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM