Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $bdd = new PDO('mysql:host='.$sql_serveur.';dbname='.$sql_bdd.'', $sql_user, $sql_mdp);
- if(isset($_GET['user'])){
- $user = (String) trim($_GET['user']);
- $req = $DB->query("SELECT *
- FROM utilisateur
- WHERE nom LIKE ?
- LIMIT 10",
- array("$user%"));
- $req = $req->fetchALL();
- foreach($req as $r){
- ?>
- <div style="margin-top: 20px 0; border-bottom: 2px solid #ccc">
- <?= $r['nom'] . " " . $r['prenom'] ?>
- </div>
- <?php
- } }
- <div class="form-group">
- <input class="form-control" type="text" id="search-user" value="" placeholder="Rechercher un ou plusieurs utilisateurs"/>
- </div>
- <div style="margin-top: 20px">
- <div id="result-search"></div> <!-- C'est ici que nous aurons nos résultats de notre recherche -->
- </div>
- $(document).ready(function(){
- $('#search-user').keyup(function(){
- $('#result-search').html('');
- var utilisateur = $(this).val();
- if(utilisateur != ""){
- $.ajax({
- type: 'GET',
- url: 'php/user_research.php',
- data: 'user=' + encodeURIComponent(utilisateur),
- success: function(data){
- if(data != ""){
- $('#result-search').append(data);
- }else{
- document.getElementById('result-search').innerHTML = "<div style='font-size: 20px; text-align: center; margin-top: 10px'>Aucun utilisateur</div>"
- }
- }
- });
- }
- });
- });
Add Comment
Please, Sign In to add comment