How to add rowspan and colspan using PEAR HTML_Table?

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

      

I need a rowpan of 2 for Name and a colspan of 2 for rest. How to do it? use setCellAttributes()

?

+3


source to share


1 answer


<?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 a function setCellAttributes()

and specify the cell number

+2


source







All Articles