// Change sort column direction
// in order asc->desc->none->asc
//
- function sort_table($col=null)
+ function sort_table($col)
{
$ord = $this->columns[$col]['ord'];
$ord = ($ord == '') ? 'asc' : (($ord == 'asc') ? 'desc' : '');
$flds = array($flds);
}
foreach ($flds as $colnum=>$coldef) {
- if (!is_numeric($colnum)) { // 'colname'=>params
+ if (is_string($colnum)) { // 'colname'=>params
$h = $colnum;
$c = $coldef;
} else { // n=>params
$h = $coldef;
$c = 'text';
}
- $c = '';
}
- if (!is_array($c)) // params is simple column type
+ if (is_string($c)) // params is simple column type
$c = array('type'=>$c);
if (!isset($c['type']))
return "SELECT COUNT($group) FROM $from $where";
}
- $sql = "$select FROM $from $where GROUP BY $group";
+ $sql = "$select FROM $from $where";
+ if($group) $sql.= " GROUP BY $group";
$ord = array();
foreach( $this->columns as $col) {
global $Ajax;
$page = find_submit($this->name.'_page_', false);
- $sort = find_submit($this->name.'_sort_', false);
+ $sort = find_submit($this->name.'_sort_', true);
if ($page) {
$this->change_page($page);
if ($page == 'next' && !$this->next_page ||
if ($page == 'prev' && !$this->prev_page ||
$page == 'first' && !$this->first_page)
set_focus($this->name.'_page_next');
- } elseif ($sort) {
+ } elseif ($sort != -1) {
$this->sort_table($sort);
} else
$this->query();