I'm trying to create my user.class.php constructor but I don't know really much about POO so I'm going to tell you what I'm doing and I hope you could help me.
user.class.php
class user {
private $fullname;
private $age;
private $email;
private $sex;
private $nacionality;
public function __construct($usrId){
$mysqli = new connection_mysqli(); // I've already implemented this and it works.
$query = "SELECT * FROM USERS WHERE USER_ID = $userId";
if ($result = $mysqli->query($query)) {
$userData = $result->fetch_assoc();
$this->fullname = $userData['fullname'];
$this->age = $userData['age'];
$this->email = $userData['email'];
//.....
}
parent::__construct($usrId);
}
}
What I'm going to do on my index.php is this:
index.php
<?php
include('scripts/class/user.class.php');
$user = new user($_SESSION['userid'];
echo $user->fullname;
?>
So, is this going to work right? Is this well-programmed? Any tips?