Bonjour me revoilà,
J'ai fait un module de recherche (on m'a beaucoup aidé LOL) qui affiche des données mais j'avais deja fait un CSS mais comment le relié ?
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php // 1- récupération $matricule_search = ( !empty($_POST['matricule_search']) )? $_POST['matricule_search'] : ''; $nom_search = ( !empty($_POST['nom_search']) )? $_POST['nom_search'] : ''; $prenom_search = ( !empty($_POST['prenom_search']) )? $_POST['prenom_search'] : ''; // 2- initialisation $where = array(); $params = array(); // 3- construction de la requête if( !empty($matricule_search) ) { $where[] = " (matricule_employe LIKE ?) "; $params[] = '%'.$matricule_search.'%'; } if( !empty($nom_search) && !empty($prenom_search) ) { $where[] = " (nom_employe LIKE ? AND prenom_employe LIKE ?) "; $params[] = '%'.$nom_search.'%'; $params[] = '%'.$prenom_search.'%'; } // 4- clause WHERE $where = ( !empty($where) )? " WHERE " . implode( " OR ", $where ) : ""; // OR : l'un OU l'autre // 5- finalisation : $sql = "SELECT * FROM employe_table" . $where . ""; $data=array(); $db = include 'connect_bdd.php'; try { $stmt = $db->prepare( $sql ); $stmt->execute( $params ); while($row= $stmt->fetch(PDO::FETCH_ASSOC)){ $data[]=$row; } unset($db); if(count($data)>0){ $table ='<table>'."\n"; $table.='<caption>Le résultat de vos recherches </caption>'."\n"; $table.='<thead>'."\n"; $table.='<tr><th>Matricule</th><th>Nom</th> <th>Prenom</th><th>Date de naissance</th><th>Date d embauche</th><th>Photo</th><th>Contrat</th><th><Fonction</th><th>Statut</th><th>Carte d identite</th><th>Carte BTP</th></tr>'."\n"; $table.='</thead>'."\n"; $table.='<tbody>'."\n"; foreach($data as $donnee){ $table.='<tr><td>'.$donnee['matricule_employe'].'</td><td>'.$donnee['nom_employe'].'</td><td>'.$donnee['prenom_employe'].'</td><td>'.$donnee['datenaiss_employe'].'</td><td>'.$donnee['date_embauche_employe'].'</td> <td>'.$donnee['photo_employe'].'</td><td>'.$donnee['contrat_employe'].'</td><td>'.$donnee['fonction_employe'].'</td><td>'.$donnee['statut_employe'].'</td><td>'.$donnee['carte_identite_employe'].'</td><td>'.$donnee['carte_btp_employe'].'</td></tr>'."\n"; } $table.='</tbody>'."\n"; $table.='</table>'."\n"; echo $table; } else{ echo 'Aucun resultat pour cette requete'; } } catch (Exception $e) { echo "Erreur ! " . $e->getMessage() . "<br/>"; } ?>
Merci pour vos futur réponses
J'aimerais que m'explique un peu en faite
PS : Pour plus d'infos n'hésitez pas
Partager