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->add(""); $this->add(""); $this->add(""); if($this->data !== false) { $i=0; foreach($this->data AS $row) { if($i == 0) { $this->add(""); foreach($row AS $key=>$dontcare) $this->add(""); $this->add(""); } $this->add(""); foreach($row AS $key=>$val) $this->add(""); $this->add(""); $i++; } return $this->html; } else { return "Sorry, your query returned zero results."; } } } ?>
". $this->title ."
". ucwords(str_replace('_', ' ', $key)) ."
$val