Generating table without loop using example_table_base.php
Added by Steve Koontz about 11 years ago
I'm using example_table_base.php to build a basic page with tables. I'd like to build the table without the complexity of the loop. But when I remove the 'for' command, only the header shows on the page. How can I remove the 'for' command and still view the tables? Below is the code within the loop.
for ($j = 0; $j < 4; $j ++) {
$aRow = Array();
$aRow[0]['TEXT_ALIGN'] = 'L';
$aRow[0]['TEXT'] = "test";
$aRow[0]['TEXT_SIZE'] = 15;
$aRow[0]['BACKGROUND_COLOR'] = array(255 - $rgb_b, $rgb_g, $rgb_r);
$aRow[1]['TEXT'] = "Test Text Column"; $aRow[1]['TEXT_SIZE'] = 13; $aRow[1]['BACKGROUND_COLOR'] = array($rgb_r, $rgb_g, $rgb_b); $aRow[2]['TEXT'] = "Test Text Column 2"; $aRow[2]['TEXT_SIZE'] = 29; $aRow[2]['BACKGROUND_COLOR'] = array($rgb_b, $rgb_g, 220); $aRow[2]['TEXT_COLOR'] = array(80, 20, $rgb_g); $oTable->addRow($aRow); $aRow2 = Array(); $aRow2[0]['TEXT_ALIGN'] = 'L'; $aRow2[0]['TEXT'] = "again"; $aRow2[0]['TEXT_SIZE'] = 15; $aRow2[0]['BACKGROUND_COLOR'] = array(255 - $rgb_b, $rgb_g, $rgb_r); $aRow2[1]['TEXT'] = "Colspan Example - Center Align you are here"; $aRow2[1]['COLSPAN'] = 2; $aRow2[1]['BACKGROUND_COLOR'] = array($rgb_b, 50, 50); $aRow2[1]['TEXT_COLOR'] = array(255, 255, $rgb_g); $aRow2[1]['TEXT_ALIGN'] = "C"; $oTable->addRow($aRow2);
}
Replies (1)
RE: Generating table without loop using example_table_base.php - Added by Andrei Bintintan almost 11 years ago
The command $oTable->addRow($aRow); adds a table row.
I really don't see why, if your remove the for command only the header rows are displayed. That means that no rows are added.
Upload a complete example file.