Good!
It's the following, I'm developing a website that consists of a user seeing the state of their equipment while it's being repaired. But I'm having trouble viewing a user's product for him.
For example: The administrator inserts a product into the database with a certain ID, and then the client logs in to the website and should be able to see your product ...
I created the following tables - > Users, Equipment, and user_equipment.
Here's what I did:
DataAcess.php (Serves to connect the database)
Function to fetch the records:
function getRegistos(){
$query = "SELECT *, DATEDIFF(NOW(),dataDeEntrada) as diferenca FROM 'equipamentos' WHERE 1";
$this->connect();
$res = $this->execute($query);
$this->disconnect();
return $res;
}
Function to insert record
function inserirRegisto($id_utilizador, $nome, $tipo, $estado, $marca, $modelo, $sintoma, $orcamento) {
$query = "insert into equipamentos
(id_utilizador, nome, tipo, estado, marca, modelo, sintoma, orcamento)
values
('$id_utilizador', '$nome','$tipo','$estado','$marca', '$modelo','$sintoma','$orcamento')";
$this->connect();
$this->execute($query);
$this->disconnect();
}
And then to get the records I did this:
$id = $_SESSION['id'];
include_once('DataAccess.php');
$da = new DataAccess();
$res = $da->getEquipamento($id);
while($row = mysqli_fetch_object($res)){ ... }
I need to get all the devices of a certain user by their ID but I do not know how I can do it. I know that the user_table table will help me but I still do not know how.