member_id = $id; $this->mysqli = $mysqli; $this->populateStats(); } function populateStats() { //get member name $statement = "SELECT name from icono.raid_members where id = ?"; $statement = $this->mysqli->prepare($statement); $statement->bind_param("i", $this->member_id); $statement->execute() or die(mysqli_error()); $statement->bind_result($this->name); $statement->fetch(); $statement->close(); //get total raids $statement = "SELECT Count(*) as raid_count FROM icono.raid_attendance WHERE member_id = ? AND active ='1' GROUP BY member_id"; $statement = $this->mysqli->prepare($statement); $statement->bind_param("i", $this->member_id); $statement->execute() or die (mysqli_error()); $statement->bind_result($this->raid_count); $statement->fetch(); $statement->close(); //get loot count $statement = "SELECT name, tier_id, COUNT(*) as cnt FROM icono.raid_loot LEFT JOIN icono.loot_class on class_id = icono.loot_class.id where member_id = ? group by class_id, tier_id"; $statement = $this->mysqli->prepare($statement); $statement->bind_param("i", $this->member_id); $statement->execute() or die (mysqli_error()); $statement->bind_result($class, $tier, $count); while($statement->fetch()) { $this->loot_count["$class"]["$tier"] = $count; } $statement->close(); } function memberExists() { if(!empty($this->name)) return true; return false; } function getRaidCount(){ return $this->raid_count; } function getLootCount($class, $tier) { if(strtolower($tier) == "total") { $total = 0; if(isset($this->loot_count[$class])) foreach($this->loot_count[$class] as $v) $total += $v; return $total; } return isset($this->loot_count[$class][$tier]) ? $this->loot_count[$class][$tier] : 0; } function getRatio($class){ if($this->getLootCount($class, "total") == 0) return $this->getRaidCount(); return round($this->getRaidCount() / $this->getLootCount($class, "total"), 2); } function getName(){ return $this->name; } function getLoot() { return $this->loot_count; } function display() { if(!isset($this->loot_count)) return; $output = ""; foreach($this->loot_count as $k => $v){ $output .= ""; } $output .= "
Raid Statistics for " . $this->name . "
Raids " . $this->getRaidCount() . " Tier 5 Tier 6 Tier 7 Total Ratio
View Extra details
$k " . $this->getLootCount("$k","5") . " " . $this->getLootCount("$k","6") . " " . $this->getLootCount("$k","7") . " " . $this->getLootCount("$k","total") . " " . $this->getRatio("$k"). "
"; echo $output; } } ?>