1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Recherche</title>
<link rel="stylesheet" href="../Parc_Transformateur.css" />
<?php include_once("menu_admin.php");?>
<script type="application/javascript" charset="utf-8" src="http://code.jquery.com/jquery-1.6.3.min.js"></script>
<script type="application/javascript">
function filterLists() {
// ici on récupère les valeurs sélectionnées pour chaque liste avec les sélecteurs de jQuery
var identifiant = $('#identifiant option:selected').val();
var type = $('#type option:selected').val();
var puissance = $('#puissance option:selected').val();
var qtite_huile = $('#qtite_huile option:selected').val();
var valeur = $('#valeur option:selected').val();
var fusible = $('#fusible option:selected').val();
var nom = $('#nom option:selected').val();
var gdo = $('#gdo option:selected').val();
var date = $('#date option:selected').val();
var choix = $('#choix option:selected').val();
// on fait notre appel ajax paramétré (pas besoin de s'occuper de l'implémentation du XMLHttpRequest, jQuery le fait pour toi)
$.ajax({
type: 'POST', // méthode de transmission des données
url: 'filterLists.php', // script à exécuter sur le serveur
data: 'identifiant='+identifiant+'&type='+type+'&puissance='+puissance+'&qtite_huile='+qtite_huile+'&valeur='+valeur,+'&fusible='+fusible,+'&nom='+nom,+'&gdo='+gdo,+'&date='+date,+'&choix='+choix, // données à passer au script via le tableau $_POST
dataType: 'xml', // type des données attendues en retour : ici xml
cache: false,
success: function(response) { // traitement du résultat (= données reçues du serveur) une fois l'appel ajax réussi
var code;
// vu que la réponse est au format xml, on demande à jquery de trouver des noeuds spécifiques
// et si ces noeuds contiennent des données alors on remplace les données des listes liées par celles renvoyées par le serveur
// en clair : on remplace si nécessaire l'ensemble des lignes <option value=""></option> pour chaque liste qui n'a pas encore de sélection
if ((code = $(response).find('identifiant').text()).length) $('#identifiant').html(code);
if ((code = $(response).find('type').text()).length) $('#type').html(code);
if ((code = $(response).find('puissance').text()).length) $('#puissance').html(code);
if ((code = $(response).find('qtite_huile').text()).length) $('#qtite_huile').html(code);
if ((code = $(response).find('valeur').text()).length) $('#valeur').html(code);
if ((code = $(response).find('fusible').text()).length) $('#fusible').html(code);
if ((code = $(response).find('nom').text()).length) $('#nom').html(code);
if ((code = $(response).find('gdo').text()).length) $('#gdo').html(code);
if ((code = $(response).find('nom').text()).length) $('#nom').html(code);
if ((code = $(response).find('date').text()).length) $('#date').html(code);
if ((code = $(response).find('choix').text()).length) $('#choix').html(code);
if ((code = $(response).find('table').text()).length) $('#table').html(code);
}
});
}
</script>
<style type="text/css">
body { font-family: "arial"; }
table { width: 600px;;}
table, tr, th, td { border: 1px solid black; border-collapse: collapse; padding: 4px;}
.alignr { text-align: right; }
.alignc { text-align: center; }
</style>
</head>
<body>
<?php
// ICI MODIFIEZ LE PARAMETRAGE
// Connexion à la base de données
$server = 'localhost';
$user = 'root';
$dbName = 'test';
$cnx = mysql_connect($server, $user);
$db = mysql_select_db($dbName);
// Au démarrage, aucune sélection : on extrait toutes les données individuellement pour chaque liste
// identifiant
$sql = 'SELECT identifiant FROM installation ORDER BY id;';
$qry = mysql_query($sql);
while($row = mysql_fetch_row($qry)) {
$identifiant[] = $row[0];
}
// type
$sql = 'SELECT type FROM installation ORDER BY id;';
$qry = mysql_query($sql);
while($row = mysql_fetch_row($qry)) {
$type[] = $row[0];
}
// puissance
$sql = 'SELECT puissance FROM installation ORDER BY id;';
$qry = mysql_query($sql);
while($row = mysql_fetch_row($qry)) {
$puissance[] = $row[0];
}
// type
$sql = 'SELECT qtite_huile FROM installation ORDER BY id;';
$qry = mysql_query($sql);
while($row = mysql_fetch_row($qry)) {
$qtite_huile[] = $row[0];
}
// type
$sql = 'SELECT valeur FROM installation ORDER BY id;';
$qry = mysql_query($sql);
while($row = mysql_fetch_row($qry)) {
$valeur[] = $row[0];
}
// type
$sql = 'SELECT fusible FROM installation ORDER BY id;';
$qry = mysql_query($sql);
while($row = mysql_fetch_row($qry)) {
$fusible[] = $row[0];
}
// type
$sql = 'SELECT nom FROM installation ORDER BY id;';
$qry = mysql_query($sql);
while($row = mysql_fetch_row($qry)) {
$nom[] = $row[0];
}
// gdo
$sql = 'SELECT gdo FROM installation ORDER BY id;';
$qry = mysql_query($sql);
while($row = mysql_fetch_row($qry)) {
$gdo[] = $row[0];
}
$sql = 'SELECT date FROM installation ORDER BY id;';
$qry = mysql_query($sql);
while($row = mysql_fetch_row($qry)) {
$date[] = $row[0];
}
$sql = 'SELECT choix FROM installation ORDER BY id;';
$qry = mysql_query($sql);
while($row = mysql_fetch_row($qry)) {
$choix[] = $row[0];
}
// DONNES DE LA TABLE
$sql = "SELECT * FROM installation ORDER BY id;";
$qry = mysql_query($sql);
while($row = mysql_fetch_assoc($qry)) {
$data[] = $row;
}
// pour chaque liste il faut prévoir leur retrait du filtre
// en insérant une ligne vide en début de liste : <option value=""></option>
?>
<div align="center">
<p><strong>TRANSFORMATEURS INSTALLES</strong></p>
<p>Sélectionnez de un à plusieurs critères de recherche.</p>
<form id="frmRecherche">
<!-- Liste des jours -->
<label for="idtifiant">Identifiant</label>
<select id="identifiant" onchange="filterLists();">
<option value=""></option>
<?php foreach($identifiant as $identifiant): ?>
<option value="<?php echo $identifiant; ?>"><?php echo $identifiant; ?></option>
<?php endforeach; ?>
</select>
<!-- Liste des type -->
<label for="type">Type</label>
<select id="type" onchange="filterLists();">
<option value=""></option>
<?php foreach($type as $untype): ?>
<option value="<?php echo $untype; ?>"><?php echo $untype; ?></option>
<?php endforeach; ?>
</select>
<!-- Liste des puissances -->
<label for="puissance">Puissance</label>
<select id="puissance" onchange="filterLists();">
<option value=""></option>
<?php foreach($puissance as $unpuissance): ?>
<option value="<?php echo $unpuissance; ?>"><?php echo $unpuissance; ?></option>
<?php endforeach; ?>
</select>
<!-- Liste des qtite_huile -->
<label for="qtite_huile">Quantite huile</label>
<select id="qtite_huile" onchange="filterLists();">
<option value=""></option>
<?php foreach($qtite_huile as $unqtite_huile): ?>
<option value="<?php echo $unqtite_huile; ?>"><?php echo $unqtite_huile; ?></option>
<?php endforeach; ?>
</select>
<!-- Liste des type -->
<label for="fusible">Fusible</label>
<select id="fusible" onchange="filterLists();">
<option value=""></option>
<?php foreach($fusible as $unfusible): ?>
<option value="<?php echo $unfusible; ?>"><?php echo $unfusible; ?></option>
<?php endforeach; ?>
</select>
<!-- Liste des type -->
<label for="date">Date</label>
<select id="date" onchange="filterLists();">
<option value=""></option>
<?php foreach($date as $undate): ?>
<option value="<?php echo $undate; ?>"><?php echo $undate; ?></option>
<?php endforeach; ?>
</select>
<!-- Liste des type -->
<label for="choix">Choix</label>
<select id="choix" onchange="filterLists();">
<option value=""></option>
<?php foreach($choix as $unchoix): ?>
<option value="<?php echo $unchoix; ?>"><?php echo $unchoix; ?></option>
<?php endforeach; ?>
</select>
<!-- Liste des code gdo -->
<label for="gdo">Code GDO</label>
<select id="gdo" onchange="filterLists();">
<option value=""></option>
<?php foreach($gdo as $gdo): ?>
<option value="<?php echo $gdo; ?>"><?php echo $gdo; ?></option>
<?php endforeach; ?>
</select>
<!-- Liste des communes -->
<label for="nom">nom</label>
<select id="nom" onchange="filterLists();">
<option value=""></option>
<?php foreach($nom as $id => $nom): ?>
<option value="<?php echo $id; ?>"><?php echo $nom; ?></option>
<?php endforeach; ?>
</select>
<!-- Liste des valeurs pcbs -->
<label for="valeur">valeur</label>
<select id="valeur" onchange="filterLists();">
<option value=""></option>
<?php foreach($valeur as $id => $valeur): ?>
<option value="<?php echo $id; ?>"><?php echo $valeur; ?></option>
<?php endforeach; ?>
</select>
</form>
<!-- Données de la table -->
<table>
<thead>
<tr>
<th>IDENTIFIANT</th>
<th>TYPE</th>
<th>PUISSANCE</th>
<th>HUILE</th>
<th>PCB</th>
<th>FUSIBLE?</th>
<th>COMMUNE</th>
<th>GDO</th>
<th>DATE</th>
<th>CHOIX</th>
</tr>
</thead>
<tbody id="table">
<?php foreach($data as $row): ?>
<tr>
<td class="alignc"><?php echo $row['identifiant']; ?></td>
<td class="alignc"><?php echo $row['type']; ?></td>
<td class="alignc"><?php echo $row['puissance']; ?></td>
<td class="alignc"><?php echo $row['qtite_huile']; ?></td>
<td class="alignc"><?php echo $row['valeur']; ?></td>
<td class="alignc"><?php echo $row['fusible']; ?></td>
<td class="alignc"><?php echo $row['nom']; ?></td>
<td class="alignc"><?php echo $row['gdo']; ?></td>
<td class="alignc"><?php echo $row['date']; ?></td>
<td class="alignc"><?php echo $row['choix']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div>
</body>
</html> |
Partager