1 database_example.module database_example_list()

Renders a list of entries in the database.

Related topics

File

modules/examples/database_example/database_example.module, line 333
Hook implementations for the Database Example module.

Code

function database_example_list() {
  $output = '';

  // Get all entries in the database_example table.
  if ($entries = database_example_entry_load()) {
    $rows = array();
    foreach ($entries as $entry) {
      // Sanitize the data before handing it off to the theme layer.
      $rows[] = array_map('check_plain', (array) $entry);
    }
    // Make a table for them.
    $header = array(t('Id'), t('uid'), t('Name'), t('Surname'), t('Age'));
    $output .= theme('table', array('header' => $header, 'rows' => $rows));
  }
  else {
    backdrop_set_message(t('No entries have been added yet.'));
  }
  return $output;
}