Phan trang (Pager)

  1. /**
  2.  * Viec phan trang co the duoc thuc hien kha don gian voi Drupal.
  3.  *
  4.  * Thi du, tao mot trang:
  5.  * - liet ke cac nguoi dung hop le cua he thong,
  6.  * - gioi han trinh bay moi trang la 50:
  7.  */
  8. function mypage_handler () {
  9. $limit = 50;
  10. $query = pager_query ("SELECT * FROM {users} WHERE status = 1", $limit);
  11. $rows = array ();
  12. while ($v = db_fetch_array ($query)) {
  13. foreach ($v as $key => $val) {
  14. $cells[] = $val;
  15. }
  16. $rows[] = $cells;
  17. unset ($cells);
  18. }
  19. return theme ('table', null, $rows) . theme ('pager', NULL, $limit);
  20. }