Afficher une table sql dans un tableau php
Posté : 28 déc. 2016, 01:01
Depuis quelque jours je bloque sur l'affichage complet d'une table de ma base de données pour la gestion des droits d'accès.
Type d'utilisateur : EMPLOYES ADMIN SUPER-USER TECHNICIEN. par rapport au type d'utilisateur les droits d'accès aux pages sont assignés en cliquant sur un bouton (passe au rouge quand cet type d'utilisateur n'est pas autoriser au vert si c'est le contraire.
J'ai vu qu'il fallait utiliser "SHOW FULL COLUMNS FROM TABLE_NAME".
A cet niveau pas de probleme, mais ce n'est que la 1ere ligne de ma table qui s'affiche quand j'ajoute des conditions.
Voici mon code
Quelqu'un peut il m'aider ? SVP
Type d'utilisateur : EMPLOYES ADMIN SUPER-USER TECHNICIEN. par rapport au type d'utilisateur les droits d'accès aux pages sont assignés en cliquant sur un bouton (passe au rouge quand cet type d'utilisateur n'est pas autoriser au vert si c'est le contraire.
J'ai vu qu'il fallait utiliser "SHOW FULL COLUMNS FROM TABLE_NAME".
A cet niveau pas de probleme, mais ce n'est que la 1ere ligne de ma table qui s'affiche quand j'ajoute des conditions.
Voici mon code
Code : Tout sélectionner
<?php
echo '
<table id="example2" class="table table-bordered table-hover">
<tr>
<th>Nom</th>
<th>Description</th>
<th>Utilisateur</th>
<th>Utilisateur avec pouvoir</th>
<th>Superviseur</th>
<th>Technicien</th>
<th>Administrateur</th>
</tr>';
$requete = mysql_query("show full columns FROM dem_rights") or die(mysql_error());
while($info = mysql_fetch_array($requete))
{
if ($info[0]!='id_rights' && $info[0]!='profile')
{
//special char
$info['Comment']=$info['Comment'];
echo '
<tr id="'.$info['0'].'">
<td>'.$info['0'].'</td>
<td>'.$info['Comment'].'</td>
<td>
<center>';
$requete = mysql_query("SELECT * FROM dem_rights where profile LIKE '2%'");
$rv = mysql_fetch_array($requete) or (mysql_error());
if($rv[$info[0]]!=0)
{
echo'
<button onclick=\'window.location.href="./index.php?page=admin&subpage=profile&value=0&object='.$info[0].'&profile=2";\' class="btn btn-xs btn-success">
<i class="icon-ok bigger-120"></i>
</button>
';
} else {
echo'
<button onclick=\'window.location.href="./index.php?page=admin&subpage=profile&value=2&object='.$info[0].'&profile=2";\' class="btn btn-xs btn-danger">
<i class="icon-ban-circle bigger-120"></i>
</button>
';
}
echo'
</center>
</td>
<td>
<center>';
//find value
$requete = mysql_query("SELECT FROM dem_rights where profile LIKE '1%'");
$rv = mysql_fetch_array($requete) or (mysql_error());
if($rv[$info[0]]!=0)
{
echo'
<button onclick=\'window.location.href="./index.php?page=admin&subpage=profile&value=0&object='.$info[0].'&profile=2";\' class="btn btn-xs btn-success">
<i class="icon-ok bigger-120"></i>
</button>
';
} else {
echo'
<button onclick=\'window.location.href="./index.php?page=admin&subpage=profile&value=2&object='.$info[0].'&profile=2";\' class="btn btn-xs btn-danger">
<i class="icon-ban-circle bigger-120"></i>
</button>
';
}
echo'
</center>
</td>
<td>
<center>';
//find value
$requete = mysql_query("SELECT * FROM dem_rights where profile LIKE '3%'");
$rv = mysql_fetch_array($requete) or (mysql_error());
if($rv[$info[0]]!=0)
{
echo'
<button onclick=\'window.location.href="./index.php?page=admin&subpage=profile&value=0&object='.$info[0].'&profile=2";\' class="btn btn-xs btn-success">
<i class="icon-ok bigger-120"></i>
</button>
';
} else {
echo'
<button onclick=\'window.location.href="./index.php?page=admin&subpage=profile&value=2&object='.$info[0].'&profile=2";\' class="btn btn-xs btn-danger">
<i class="icon-ban-circle bigger-120"></i>
</button>
';
}
echo'
</center>
</td>
<td>
<center>';
//find value
$requete = mysql_query("SELECT * FROM dem_rights where profile LIKE '0%'");
$rv = mysql_fetch_array($requete) or (mysql_error());
if($rv[$info[0]]!=0)
{
echo'
<button onclick=\'window.location.href="./index.php?page=admin&subpage=profile&value=0&object='.$info[0].'&profile=2";\' class="btn btn-xs btn-success">
<i class="icon-ok bigger-120"></i>
</button>
';
} else {
echo'
<button onclick=\'window.location.href="./index.php?page=admin&subpage=profile&value=2&object='.$info[0].'&profile=2";\' class="btn btn-xs btn-danger">
<i class="icon-ban-circle bigger-120"></i>
</button>
';
}
echo'
</center>
</td>
<td>
<center>';
//find value
$requete = mysql_query("SELECT * FROM dem_rights where profile LIKE '4%'");
$rv = mysql_fetch_array($requete) or (mysql_error());
if($rv[$info[0]]!=0)
{
echo'
<button onclick=\'window.location.href="./index.php?page=admin&subpage=profile&value=0&object='.$info[0].'&profile=2";\' class="btn btn-xs btn-success">
<i class="icon-ok bigger-120"></i>
</button>
';
} else
{
echo'
<button onclick=\'window.location.href="./index.php?page=admin&subpage=profile&value=2&object='.$info[0].'&profile=2";\' class="btn btn-xs btn-danger">
<i class="icon-ban-circle bigger-120"></i>
</button>
';
}
echo'
</center>
</td>
</tr>';
}
}
echo'
</tbody>
</table>';
?>