hi, here is my code:
class DBCon{ private $con; private $host; private $user; private $password; private $dataBase; function __construct(){ $this->host = 'localhost'; $this->user = 'root'; $this->password = ''; $this->dataBase = 'import'; $this->con = new mysqli($this->host, $this->user,$this->password, $this->dataBase); } function connectionString(){ if($this->con->error){ echo "Sikertelen adatbázis kapcsolódás"; die(); } else{ return $this->con; } } }
class showUser{
private userId;
function __construct($id){
$this->userId=$id;
}
function showData(){
$q="select * from user where id=".$this->id;
$r=$con->query($q);
while($row=$r->fetch_assoc()){
echo $row['name'];
}
}
}
I dont know how to add the $con value to showuser class, and make the showdata() function work.
Thank you for your help.