census_page

Definition

census_page()
census/census.module, line 35

Description

Default page

Code

function census_page() {
  $header = array(
    array('data' => t('Country'), 'field' => 'cid', 'sort' => 'ASC'),
     array('data' => t('Birth rate / 1000'), 'field' => 'births'),
    array('data' => t('Death rate / 1000'), 'field' => 'deaths'),   
        array('data' => t('Growth rate (%)'), 'field' => 'growth')
  );
  // grab the data from the external db
  db_set_active('external');
  $result = db_query("SELECT cid, country, births, deaths, growth FROM {country}". tablesort_sql($header));
  // switch back to Drupal before doing anything else!
  db_set_active('default');
  while ($data = db_fetch_object($result)) {
    $items[] = l($data->country, 'census/country/'. $data->cid);
    $rows[] = array(l($data->country, 'census/country/'. $data->cid), $data->births, $data->deaths, $data->growth .'%');
  }
  return theme('table', $header, $rows);
//  return theme('item_list', $items);
}