getMessage(); } $query = "SELECT * FROM treasureclassex WHERE `Treasure Class` != ''"; $res = array_filter(PDO_FetchAll($query)); $dropChances = []; foreach ($res as $r) { $total = (int) $r['NoDrop']; for ($i = 1; $i <= 10; $i++) { if (!empty($r["Item$i"])) { $total += (int) $r["Prob$i"]; // total will be denominator $ic = $r["Item$i"]; // get item code $prob = (int) $r["Prob$i"]; // now every item divided by denominator = dropchance $dropChances[$r['Treasure Class']]["nd"] =$r['NoDrop']; $dropChances[$r['Treasure Class']]["nodrop"] = round(((int) $r['NoDrop'] / $total) * 100, 2); $dropChances[$r['Treasure Class']]["items"]["Item$i"]["code"] = $ic; $dropChances[$r['Treasure Class']]["items"]["Item$i"]["prob"] = $prob; $dropChances[$r['Treasure Class']]["items"]["Item$i"]["chance"] = round(($prob / $total) * 100, 2); } } } ?>
Treasure Class | NoDrop % | Item1 | Item2 | Item3 | Item4 | Item5 | Item6 | Item7 | Item8 | Item9 | Item10 |
---|---|---|---|---|---|---|---|---|---|---|---|
$treasureClass | "; echo "NoDrop : {$row["nd"]} Chance: $nodrop | ";
foreach ($row['items'] as $item => $values) {
echo "
| ";
}
echo "