$ref = $DB_site->query_first(" SELECT COUNT(*) AS referrals, user.username, user.userid FROM " . TABLE_PREFIX . "user AS users LEFT JOIN " . TABLE_PREFIX . "user ON (users.referrerid = user.userid) WHERE users.referrerid <> 0 GROUP BY users.referrerid ORDER BY referrals DESC LIMIT 1 ");