I am new to drupal. I am trying to create a function that will retrieve rows from a database and display the results.From the tutorials I have read, I am trying to implement a function I have created but no results are displayed. There's just a whitespace. Where might I be going wrong? Here is my code.
function print_users(){
$query = "SELECT first_name, middle_name, last_name FROM {registered_users}";
$header = array(
array('data' => t('Cell 1'), 'field' => 'first_name', 'sort' => 'ASC'),
array('data' => t('Cell 2'), 'field' => 'middle_name'),
array('data' => t('Cell 3'), 'field' => 'last_name'),
);
$q = db_query($query . tablesort_sql($header));
while ($r = db_fetch_array($q)) {
$rows[] = $r;
}
print theme('table', $header, $rows);
}
and am calling it as follows via a menu link
$items['view_users'] = array(
'title' => "view",
'description' => 'Viewing service',
'page callback' => "print_users",
'access callback' => TRUE,
'weight' => '2',
);