Posted By

weitzman on 08/16/06


Tagged

textmate drupal


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

panatlantica
vali29
DanS42


query and iterate


 / Published in: PHP
 

  1. \$sql = "$1";
  2. \$header = array(
  3. array('data' => t('$2'), 'field' => '$3', 'sort' => '${4:asc}'),
  4. array('data' => t('$5'), 'field' => '$6'),
  5. array('data' => t('$7'), 'colspan' => '2')
  6. );
  7. \$sql .= tablesort_sql(\$header);
  8. \$result = pager_query(\$sql, 50);
  9.  
  10. \$destination = drupal_get_destination();
  11. while (\$row = db_fetch_object(\$result)) {
  12. $rows[] = array(\$row->, \$row->, array(), \$destination));
  13. }
  14.  
  15. if (\$pager = theme('pager', NULL, 50, 0, tablesort_pager())) {
  16. \$rows[] = array(array('data' => \$pager, 'colspan' => '2'));
  17. }
  18.  
  19. if (!\$rows) {
  20. \$rows[] = array(array('data' => t('$8'), 'colspan' => '2'));
  21. }
  22.  
  23. return theme('table', \$header, \$rows);

Report this snippet  

You need to login to post a comment.