<?php /** * Below are two classes, one that holds site info, and one that holds sites data. Data is generated for you. * Your task is to display this data in an informative way. * * 1. Display the data in a table. * 2. Provide links at the top of the table to sort by id, visitors, revenue, expense, and profit. * *bonus* sort the table without reloading the page using javascript or AJAX. * 3. Generate total visitors, total revenue, total expense, and total profit at end of table. * 4. Provide a link that generates an XML report containing all the data in the table. * * use $_GET or $_POST variables to pass data to the page (eg. ?sort_by=profit or ?return=XML). */ class Site { var $id, $visitors, $revenue, $expense; function Site($id = 0) { $this->id = $id; $this->visitors = rand(0,1000000); $this->revenue = rand(0,10000); $this->expense = rand(0,10000); } function displaySite() { $profit = $this->revenue - $this->expense; $html = "{$this->id}: visits={$this->visitors}, revenue={$this->revenue}, expense={$this->expense}, profit={$profit}<br>"; return $html; } } class Data { var $sites; function Data($size = 1000) { $this->sites = array(); srand(84293823); while($size-- != 0) $this->sites[] = new Site($size); } function displayData() { $html = ""; foreach($this->sites as $site) $html .= $site->displaySite(); return $html; } } $sitedata = new Data(100); echo $sitedata->displayData(); ?> LearnCareGo missions mobilization for local churches --------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. [Non-text portions of this message have been removed]