Sunday, 26 May 2013

How to make table sortable

<?php
$html = ''; 

$header = array(array('data' => 'Name', 'field' => 'name', 'sort' => 'asc'),
array('data' => 'Date of Birth', 'field' => 'date_of_birth'),'Notes'); 

$res = pager_query("SELECT name, date_of_birth, notes FROM {people}" . tablesort_sql($header), $limit = 30);  

$data = array();
 

while ($row = db_fetch_array($res)) {
  $data[] = array($row['name'], $row['date_of_birth'], $row['notes']);
}

$html .= theme('table', $header, $data);
$html .= theme('pager');
?>

No comments:

Post a Comment

Source base installation of php, mysql and apache in ubuntu/ linux

Compile and Install a LAMP(Linux/Apache/MySQL/PHP) Server from Source In the last post, I described the method to install a LAMP ser...