Bonjour à tous,
J'utilise Apache comme serveur WEB et mysql pour ma BD.
J'utilise PHP en objet afin de faciliter mes informations.
Dans ma vue (VComputer_List.php) je devrais voir tous mes ordinateurs qui sont dans ma base de donnée. Je me suis donc créé une classe de Persistance qui fait le travail de m'emmenere une array afin d'afficher le tout dans une table. Effectivement il semble trouver mes 2 pc que j'ai mis dans ma bd afin de faire des tests mes rien n'affiche dans chacune des colonnes de ma table.
Pourtant j'ai pratiquement fait un copier coller de ma table des usager et qui fonctionne très bien.
si je met un echo afin de voir si le numéro de série de l'ordinateur est trouvé il ne me sors rien du tout. ('')
Est-ce que quelqu'un pourrais voir si il y a un problème que je ne perçois pas
Persistant (getAllComputer())
------------------
public function getAllComputer()
{
include_once('Computer.class.php');
$all_pc = new ArrayObject;
$req = "SELECT * FROM inv_computer";
echo 'Request allComputer (' . $req . ') ';
$this->connect();
$res = mysqli_query($this->conn, $req);
while($row = mysqli_fetch_array($res))
{
$pc = new Computer;
echo 'Computer serial is ' . $row['sn'] . '.';
echo $row->name;
echo $row->table;
echo $row->not_null;
$pc->setSerialNumber($row['sn']);
$pc->setName($row['name']);
$pc->setNameAddress($row['nameaddress']);
$pc->setManufacturer($row['manufacturer']);
$pc->setModel($row['model']);
$pc->setProject($row['project']);
$pc->setDomain($row['domain']);
$pc->setWorkgroup($row['workgroup']);
$pc->setOSName($row['osname']);
$pc->setOSKey($row['oskey']);
$pc->setServer($row['server']);
$pc->setWorkable($row['workable']);
$pc->setInventory($row['inventory']);
$pc->setProduction($row['production']);
$pc->setFormation($row['formation']);
$all_pc->append($pc);
}
$this->disconnect();
return $all_pc;
}
private function connect()
{
$this->conn = new mysqli($this->db_host, $this->db_username, $this->db_password);
if(!$this->conn)
{
echo "Impossible de se connecter à la base.";
exit;
}
$base = mysqli_select_db($this->conn, $this->db_database);
if(!$base)
{
echo "Impossible de trouver la base de donnée.";
exit;
}
}
private function disconnect()
{
mysqli_close($this->conn);
}
-------------------
VComputer_List.php (ma vue)
---------------------
<?php
session_start();
echo '<html>
<body><title>Inventaire 1.0 - Liste des ordinateurs</title>
<h1>Réservé aux membres IT</h1>';
if(isset($_SESSION['username']))
{
$access = $_SESSION['access'];
if($access == 'ADM')
{
if(isset($_POST['delpc']))
{
include_once('class/PInventaire.class.php');
$pi =new PInventaire;
$pi->deleteComputer($_POST['delpc']);
}
echo '<h3>Bienvenue ' . $_SESSION['fname'] . ' ' . $_SESSION['lname'] . '</h3>
<br /><a href="PrincipalView.php">Page principal</a>
<br /><a href="VComputer_List.php">Rafraîchir cette page</a>
<form method="post" action="VAdd_Computer.php">
<tr><td colspan="2" align="center"><input type="submit" value="Ajouter Ordinateur"></td></tr>
</form><p />
<center>
<table border=5">
<tr>
<td bgcolor=cccccc align="center">SN</td>
<td bgcolor=cccccc align="center">Nom</td>
<td bgcolor=cccccc align="center">Manufacture</td>
<td bgcolor=cccccc align="center">Modèle</td>
<td bgcolor=cccccc align="center">Projet</td>
<td bgcolor=cccccc align="center">Système d´exploitation</td>
</tr>
';
include_once('class/PInventaire.class.php');
include_once('class/Computer.class.php');
$pi = new PInventaire;
$all_pc = $pi->getAllComputer();
foreach($all_pc as $pc)
{
echo ' <tr>
<td bgcolor=cccccc>' . $pc->getSerialNumber() . '</td>
<td bgcolor=cccccc>' . $pc->getName() . '</td>
<td bgcolor=cccccc>' . $pc->getManufacturer() . '</td>
<td bgcolor=cccccc>' . $pc->getModel() . '</td>
<td bgcolor=cccccc>' . $pc->getProject() . '</td>
<td bgcolor=cccccc>' . $pc->getOSName() . '</td>
<td colspan="2" align="center">
<form method="post" action="VModif_Computer.php">
<input type="hidden" name="modpc" value="' . $pc->getSerialNumber() . '">
</td>
<td><input type="submit" value="Modifier"></td>
</form>
<td colspan="2" align="center">
<form method="post" action="VComputer_List.php">
<input type="hidden" name="delpc" value="' . $pc->getSerialNumber() . '">
</td>
<td><input type="submit" value="Supprimer"></td>
</form>
</tr>
';
}
echo ' </table>
</center>';
}
else
{
echo '<p>Vous n´êtes pas autorisé!</p>';
echo '<a href="login.php">Page de connexion</a>';
echo '<br /><a href="PrincipalView.php">Page principal</a>';
}
}
else
{
echo '<p>Vous n´êtes pas autorisé!</p>';
echo '<a href="login.php">Page de connexion</a>';
}
echo '
</body>
</html>';
?>
-------------------------------
SpaceHamAgent