jankidudel Posted March 24, 2011 Share Posted March 24, 2011 I'm looking for someone who could test my WEB skills in overall Link to comment https://forums.phpfreaks.com/topic/231576-hey-guys-who-could-test-my-skills/ Share on other sites More sharing options...
MrXHellboy Posted March 24, 2011 Share Posted March 24, 2011 We all want to help you, but how are we supposed to do that without any code ? Link to comment https://forums.phpfreaks.com/topic/231576-hey-guys-who-could-test-my-skills/#findComment-1191637 Share on other sites More sharing options...
jankidudel Posted March 24, 2011 Author Share Posted March 24, 2011 CREATE TABLE `assignments`.`products` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` VARCHAR( 250 ) NOT NULL , `cost` DECIMAL( 10, 2 ) NOT NULL ) ENGINE = INNODB; CREATE TABLE `assignments`.`transactions` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `order_id` INT NOT NULL , `income` DECIMAL( 10, 2 ) NOT NULL , `cost` DECIMAL( 10, 2 ) NOT NULL , `data` DATE NOT NULL ) ENGINE = INNODB; CREATE TABLE `assignments`.`orders` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `client_id` INT NOT NULL , `product_id` INT NOT NULL , `data` DATE NOT NULL ) ENGINE = INNODB; CREATE TABLE `assignments`.`clients` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` INT( 250 ) NOT NULL , `lastname` INT( 250 ) NOT NULL ) ENGINE = INNODB; <?php class Myclass { protected $db; public function __construct() { $this->db = new PDO("mysql:host=localhost;dbname=zadania", "root", ""); //mysql_connect("localhost" , "root", ""); //mysql_select_db("zadania"); } public function getIncomeStatistics($month=1) { $query = "SELECT DAYOFMONTH(data) AS day, SUM(income) AS income, SUM(cost) AS cost FROM transactions GROUP BY day"; $results = $this->db->query($query); $results = $results->fetchAll(); foreach($results as $result) { $item['day'] = $result['day']; $item['profit'] = $result['income'] - $result['cost']; $return[] = $item; } return $return; } public function getOrdersStatistics($month=1){ $query = "SELECT products.name AS product, COUNT(orders.product_id) AS orders_num FROM products, orders WHERE products.id = orders.product_id GROUP BY products.id"; $results = $this->db->query($query); $results = $results->fetchAll(); foreach($results as $result) { $item['produkt'] = $result['produkt']; $item['liczba_zamowien'] = $result['liczba_zamowien']; $return[] = $item; } return $return; } public function getTopClients(){ $query = "SELECT clients.name AS client, COUNT(orders.client_id) AS orders_num , SUM(transactions.income) - SUM(transactions.cost) AS income FROM clients, orders, transactions WHERE clients.id = orders.client_id AND orders.id = transactions.order_id GROUP BY clients.id ORDER BY income DESC"; $results = $this->db->query($query); $results = $results->fetchAll(); foreach($results as $result) { $client['client'] = $result['client']; $client['orders_num'] = $result['orders_num']; $return[] = $client; } return $return; } } ?> Link to comment https://forums.phpfreaks.com/topic/231576-hey-guys-who-could-test-my-skills/#findComment-1191645 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.