Handy SQL print in table for drupal

<?php

//hook_menu
 
$items['cc2_content_check_dw'] = array(
     
'page callback' => 'cc2_content_check_dw',
     
'page arguments' => array(1),
     
'access arguments' => array('access content'),
     
'type' => MENU_CALLBACK,
  );

...

function
cc2_content_check_dw($task_nid) {
      if(
$result = db_query('SELECT * FROM `content_type_log`
                LEFT JOIN content_field_l_time using(nid) WHERE `field_l_reference_nid` = %d
                order by field_l_date_value DESC'
, $task_nid)) {

       
$td = $rows = $header = $keys = array();
        while (
$data = db_fetch_object($result)) {
            foreach (
$data as $key => $value) {
             
$td[] = $value;
             
$keys[] = $key;
          }
         
$rows[] = $td;
         
$header = $keys;
          unset(
$td, $keys);
        }
       
$out .= theme('table', $header, $rows, $attr = array("class" => 'my-table'), $caption = NULL);
      }
}

?>
Knowledge keywords: