mysql_close($con); } require_once('RGrid.php'); $params['hostname'] = 'localhost'; $params['username'] = '******'; $params['password'] = '******'; $params['database'] = 'npcc'; $sql = "SELECT gentype_id, gentype_desc FROM gentype ORDER BY gentype_id ASC"; $grid = RGrid::Create($params, $sql); /** Sorting Flag True/False */ $grid->allowSorting = false; /** Turn the column headers True/False */ $grid->showHeaders = true; /** * GRID Header */ // $grid->SetHeaderHTML('<div style="text-align: center">[This the (static) header HTML]</div>'); /** Sets nice(r) display names instead of the raw column names */ $grid->SetDisplayNames(array('gentype_id' => ' ID ', 'gentype_desc' => ' Generation Type ')); /** This hides a column from the result set. It would of course be easier and
/** * Sort an array based datagrid */ private function _sortArray($a, $b) { if (empty(RGrid::$orderby)) { RGrid::$orderby = key($a); RGrid::$orderdir = 1; // Ascending } // Ascending if (RGrid::$orderby['direction']) { if ($a[RGrid::$orderby['column']] > $b[RGrid::$orderby['column']]) { return 1; } elseif ($a[RGrid::$orderby['column']] < $b[RGrid::$orderby['column']]) { return -1; } else { return 0; } // Descending } else { if ($a[RGrid::$orderby['column']] > $b[RGrid::$orderby['column']]) { return -1; } elseif ($a[RGrid::$orderby['column']] < $b[RGrid::$orderby['column']]) { return 1; } else { return 0; } } }