Ok I got it after fiddeling with it for about 2 hours
Here is the code if any one is intrested
PHP Code:
$members = $DB_site->query("
SELECT *
FROM clan_roster
ORDER BY rank, name");
$ranklevel = $DB_site->fetch_array($members);
$rankid = $ranklevel['rank'];
$ranks = $DB_site->query("
SELECT *
FROM clan_rank
WHERE ranklevel = $rankid
");
$ranktitle = $DB_site->fetch_array($ranks);
while ($memberinfo = $DB_site->fetch_array($members))
{
$rank = $ranktitle['rank'];
EDIT: Found a bug in the old one and currently running and extra query to fix. If anyone knows how to fix this it would be appreciated.
PHP Code:
$rankids = $DB_site->query_first("
SELECT *
FROM clan_roster
ORDER BY rank, name");
$rankid = $rankids['rank'];
$ranks = $DB_site->query("
SELECT *
FROM clan_rank
WHERE ranklevel = $rankid
");
$ranktitle = $DB_site->fetch_array($ranks);
$members = $DB_site->query("
SELECT *
FROM clan_roster
ORDER BY rank, name");
while ($memberinfo = $DB_site->fetch_array($members))
{
$rank = $ranktitle['rank'];