Some serious problems with your listproducts.php
You should do this assignment on a constructor
public $database = parent::connection(); //<--- This gave you a syntax error.
Like this...
public $database;
function __construct()
{
$this->database = parent::connection();
}
Next thing comes your read()
, you need to make use of $this
keyword..
Should be..
public function read(){
$query = "SELECT name, price_in, price_out, category_products_id FROM products";
$data = $this->database->query($query); //<---- Do this way..
The fixed code..
<?php
require_once('initializing.php');
class DbPlus extends MySQLDatabaseConnection{
public $database;
function __construct()
{
$this->database = parent::connection();
}
public function read(){
$query = "SELECT name, price_in, price_out, category_products_id FROM products";
$data = $this->database->query($query);
while ( $row = $data->fetch_object()) {
echo $row->name;
}
}
}
$dbplus = new DbPLus;
$dbplus->read();