Applied joins across multiple tables in MediaWiki using variables and for loop