parent =& $parent; $this->table = $table; $this->where = $where; $this->sort = $sort; $this->order = $order; $this->page = $page; $this->perpage = $perpage; $this->fieldlist = $fieldlist; $this->html = ""; $this->title = $title; $this->whichcolor = 0; $this->script = getenv("SCRIPT_NAME"); $this->load_data(); } // Adds data to the grid. function add($string) { $this->html .= $string ."\n\n"; } // Loads data into array. function load_data() { $offset = (int)$this->page * $this->perpage; $sql = "SELECT ". $this->fieldlist ." FROM ". SQL_DB .".`". $this->table ."` WHERE ". $this->where ." ORDER BY ". $this->sort ." ". $this->order ." LIMIT $offset, ". $this->perpage; $this->data =& $this->parent->database->FetchDataSet($sql); } // Switches colors function switch_color() { if($this->whichcolor == 0) { $this->whichcolor = 1; return FORM_COLOR_TWO; } else { $this->whichcolor = 0; return FORM_COLOR_ONE; } } // Fetches the html table. function get() { $this->add("
| ". $this->title ." | "); $this->add("||||||||||||||
| ". ucwords(str_replace('_', ' ', $key)) ." | "); $this->add("||||||||||||||
| $val | "); $this->add("||||||||||||||