12 July 2012

Create table using theme table in Drupal. This is the simplest example of creating table. In the code I added link to the documentation. You can do things like add classes, caption, colgroups etc.

Source code viewer
  1. $header = array('Column 1', 'Column 2', 'Column 3');
  2. $rows = array(
  3. array('Row 1 Column 1', 'Row 1 Column 2', 'Row 1 Column 3'),
  4. array('Row 2 Column 1', 'Row 2 Column 2', 'Row 2 Column 3'),
  5. array('Row 3 Column 1', 'Row 3 Column 2', 'Row 3 Column 3'),
  6. );
  7.  
  8. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  9. echo theme('table', array('header' => $header, 'rows' => $rows));
Programming Language: PHP