PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_Table » Bug #1734

_adjustEnd() adds extra column to single column table

Details

Submitted2004-06-28 13:39 UTC
FromPhilip dot Heath at wnco dot com
Assigneddufuz
StatusClosed
PackageHTML_Table
PHP Version5.0.0RC2 (Release Candidate 2)
OSWindows XP
Roadmaps(Not assigned)

Comments

[2004-06-28 13:39 UTC] Philip dot Heath at wnco dot com

Description:
------------
HTML_Table Version 1.5

When calling setRowAttributes with a single column table, a second column gets added. After looking at the source code, it appears that the call at line 385 should be passing "0" as the column number rather than "1". I made this change in my local install, and I now get the expected behavior.

Reproduce code:
---------------
$prs = array('123', '456', '789'); // Data for the table

// Setup the table
$tableAttrs = array('style' => 'background-color: rgb(51, 255, 51); text-align: left;',
'BORDER' => 2,
'CELLPADDING' => 2,
'CELLSPACING' => 0);
$table = new HTML_Table($tableAttrs);
$table -> setAutoGrow(true);
$table -> setAutoFill('Should not see this');

// Add the data to the table
for($rn=0; $rn < count($prs); $rn++)
{
$table-> setCellContents( $rn+1, 0, $prs[$rn]);
}

// Set the headers
$table -> setHeaderContents(0, 0, "PR Number");
$hrAttrs = array("bgcolor" => "silver");
$table -> setRowAttributes(0, $hrAttrs, true);

echo $table->toHTML();

Expected result:
----------------
The page using the table above would contain a table with a single column headed with "PR Number" and the cells containing the contents of the $prs array.

Actual result:
--------------
A table with two columns the second of which is headed with "Should not see this" and whose cells contain "Should not see this".