I have a page that is supposed to output a table of values from my database. I am logged in as an admin and another page I created works just fine, outputting a form for data to be entered into the database. I have the following lines of code pertaining to the new page..

function achievementList_menu() {
$items = array();   
$items['achievementList/list'] = array(
    'title' => 'Achievement List',
    'description' => 'A list of all of my achievements',
    'page callback' => 'achievementList_generate_table',
    'access arguments' => array('access content'),
return $items;



function achievementList_generate_table() {
$header = array('ID', 'Name', 'Description', 'Points');
$rows = array();
$results = db_query("SELECT * FROM {achievements}");

foreach ($results as $row){
    $rows[] = $row;

return theme('table', array('header' => $header), array('rows' => $rows) );

The headers render fine but the $rows array does not. Any idea why?

  • 1
    Looks like you're trying to use Drupal 6 code in a Drupal 7 site. Check out the docs for theme() and this – Clive Oct 22 '14 at 23:43

I can see a few problems at first glance:

'access callback' => TRUE, will mean everyone gets access no matter what and make 'access arguments' redundant.

The default access callback is user_access, which would accept your access arguments of array('access content'). So to use that just omit the access callback line.

$items['achievementList/list'] = array( is a strange path. Generally best to keep it all lower case but that's not a requirement.

'page arguments' => array(1), will be passing in the string "list" to your achievementList_generate_table() function, but there is no point passing in a parameter that never changes and you arent actually using it, so just array() is fine for those arguments.

For more information I recommend reading all of the documentation for hook_menu().

The real problem though would be that your callback function is not returning anything for some reason.

(as per Clive's comment) I'm going to assume you are using Drupal 7. In which case your call to the theme() function is incorrect.

In drupal 7 all variables going into the theme function should be in an array, so your line should look like this:

return theme('table', array('header' => $header, 'rows' => $rows));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.