I'm trying to create a script that i can keep referring to which would display database entries. I believe my problem is when I'm trying to display the result I have no idea on how to call for mysqli and query. the ERROR I'm getting is Call to a member function fetch_row() on a non-object in
class connectDatabase {
public $category;
public $query;
public $mysqli;
public function __construct($DB_HOST, $DB_USER, $DB_PWD, $DB_NAME)
{
$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PWD, $DB_NAME);
return $this->mysqli = $mysqli;
}
public function queryInformation($category) {
$query = "SELECT * FROM postad WHERE `category` = $this->category ORDER by date desc";
return $this->query = $query;
}
public function displayResult() {
$mysqli = $this->mysqli ;
$query = $this->query;
$result = $mysqli->query($query);
while ($row = $result->fetch_row()) {
echo "$row[1] $row[2] $row[3] $row[4] </br>" ;
}
}
}
$this->categorywhen you are supposedly passing it as a parameter?