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"]; $ic = $r["Item$i"]; $prob = (int) $r["Prob$i"]; $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); } } } header("Content-Type: text/html"); ?>