par
debutant10 » 08 mai 2012, 16:57
Bonjour, J'ai appris bcps sur les affichages, mais cependant je bloque pour faire une sorte de filtre sélection pour chaque champ. càd pourvoir faire des filtre comme sur excel pour chaque champs :
voici les champs que souhaite pouvoir filtrer
echo '<tr>';
echo '<td bgcolor="#CCCCCC">'.$row['prenom'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['nom'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['titre'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['phone'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['email'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['no'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['cp'].'</td>';
//echo '<td bgcolor="#CCCCCC">'.$row['calcul'];
echo '<td';
Ci-dessous mon php qui fonctionne très bien
<html>
<head>
<title>Supprimer</title>
<link href="css/style2.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'import';
$link = mysql_connect ($host,$user,$pass) or die ('Erreur : '.mysql_error() );
mysql_select_db($db) or die ('Erreur :'.mysql_error());
$select = 'SELECT prenom,nom,titre,phone,email,no,cp FROM tfi2003_contacts ';
$select = 'SELECT prenom,nom,titre,phone,email,no,cp,(cp-no) AS calcul FROM tfi2003_contacts ';
$result = mysql_query($select,$link) or die ('Erreur : '.mysql_error() );
$total = mysql_num_rows($result);
// si on a récupéré un résultat on l'affiche.
if($total) {
// début du tableau
echo '<table bgcolor="#FFFFFF">'."\n";
// première ligne on affiche les titres prénom et surnom dans 2 colonnes
echo '<tr>';
echo '<td bgcolor="#669999"><b><u>Prénom</u></b></td>';
echo '<td bgcolor="#669999"><b><u>nom</u></b></td>';
echo '<td bgcolor="#669999"><b><u>titre</u></b></td>';
echo '<td bgcolor="#669999"><b><u>phone</u></b></td>';
echo '<td bgcolor="#669999"><b><u>email</u></b></td>';
echo '<td bgcolor="#669999"><b><u>no</u></b></td>';
echo '<td bgcolor="#669999"><b><u>cp</u></b></td>';
echo '<td bgcolor="#669999"><b><u>calcul</u></b></td>';
echo '</tr>'."\n";
// lecture et affichage des résultats sur 2 colonnes, 1 résultat par ligne.
while($row = mysql_fetch_array($result)) {
echo '<tr>';
echo '<td bgcolor="#CCCCCC">'.$row['prenom'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['nom'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['titre'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['phone'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['email'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['no'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['cp'].'</td>';
//echo '<td bgcolor="#CCCCCC">'.$row['calcul'];
echo '<td';
if($row['calcul']>=50 && $row['calcul']<=100){ echo ' bgcolor="#ffcc66"'; } else { echo ' bgcolor="#CCCCCC"'; }
echo'>'.$row['calcul'].'</td>';
echo '</tr>'."\n";
}
echo '</table>'."\n";
// fin du tableau.
}
else echo 'Pas d\'enregistrements dans cette table...';
// on libère le résultat
mysql_free_result($result);
?>
</body>
</html>
Bonjour, J'ai appris bcps sur les affichages, mais cependant je bloque pour faire une sorte de filtre sélection pour chaque champ. càd pourvoir faire des filtre comme sur excel pour chaque champs :
voici les champs que souhaite pouvoir filtrer
[php]echo '<tr>';
echo '<td bgcolor="#CCCCCC">'.$row['prenom'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['nom'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['titre'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['phone'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['email'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['no'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['cp'].'</td>';
//echo '<td bgcolor="#CCCCCC">'.$row['calcul'];
echo '<td';[/php]
Ci-dessous mon php qui fonctionne très bien
[php]<html>
<head>
<title>Supprimer</title>
<link href="css/style2.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'import';
$link = mysql_connect ($host,$user,$pass) or die ('Erreur : '.mysql_error() );
mysql_select_db($db) or die ('Erreur :'.mysql_error());
$select = 'SELECT prenom,nom,titre,phone,email,no,cp FROM tfi2003_contacts ';
$select = 'SELECT prenom,nom,titre,phone,email,no,cp,(cp-no) AS calcul FROM tfi2003_contacts ';
$result = mysql_query($select,$link) or die ('Erreur : '.mysql_error() );
$total = mysql_num_rows($result);
// si on a récupéré un résultat on l'affiche.
if($total) {
// début du tableau
echo '<table bgcolor="#FFFFFF">'."\n";
// première ligne on affiche les titres prénom et surnom dans 2 colonnes
echo '<tr>';
echo '<td bgcolor="#669999"><b><u>Prénom</u></b></td>';
echo '<td bgcolor="#669999"><b><u>nom</u></b></td>';
echo '<td bgcolor="#669999"><b><u>titre</u></b></td>';
echo '<td bgcolor="#669999"><b><u>phone</u></b></td>';
echo '<td bgcolor="#669999"><b><u>email</u></b></td>';
echo '<td bgcolor="#669999"><b><u>no</u></b></td>';
echo '<td bgcolor="#669999"><b><u>cp</u></b></td>';
echo '<td bgcolor="#669999"><b><u>calcul</u></b></td>';
echo '</tr>'."\n";
// lecture et affichage des résultats sur 2 colonnes, 1 résultat par ligne.
while($row = mysql_fetch_array($result)) {
echo '<tr>';
echo '<td bgcolor="#CCCCCC">'.$row['prenom'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['nom'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['titre'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['phone'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['email'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['no'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['cp'].'</td>';
//echo '<td bgcolor="#CCCCCC">'.$row['calcul'];
echo '<td';
if($row['calcul']>=50 && $row['calcul']<=100){ echo ' bgcolor="#ffcc66"'; } else { echo ' bgcolor="#CCCCCC"'; }
echo'>'.$row['calcul'].'</td>';
echo '</tr>'."\n";
}
echo '</table>'."\n";
// fin du tableau.
}
else echo 'Pas d\'enregistrements dans cette table...';
// on libère le résultat
mysql_free_result($result);
?>
</body>
</html>[/php]