3
Good!
The thing is, I’m developing a website that consists of a user seeing the condition of their device while it’s being repaired. But I’m having a hard time visualizing a certain user’s product for him.
For example: The administrator inserts a product into the database with a certain ID, and then the customer logs into the website and should be able to view 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 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 equipment of a certain user by their ID, but I don’t know how I can do it. I know the user_equipment table will help me but I still don’t know how.