Im gonna edit the question to make it clearer, so you can see what i have got now, and get an easier understanding of the problem.
<?php
$mysqli = new mysqli("localhost", "user", "password", "test");
class building
{
private $mysqli;
public $buildingid;
public $userid;
public $buildinglevel;
public function __construct($buildingid, $userid, \mysqli $mysqli)
{
$this->buildinglevel;
$this->mysqli = $mysqli;
}
public function getLevel()
{
return $this->mysqli->query("SELECT ".$this->buildingid." FROM worlds WHERE city_userid=".$this->userid."");
}
}
}
?>
Then I use this to create and use the function:
$cityHall = new building("cityHall",$user['id'],$mysqli);
echo $cityHall->getLevel();
This turns out blank, and nothing happens.