query and iterate


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.