You are on page 1of 1

<script>

$(document).ready(function() {
$('#search').keyup(function() {
$('#resultat').html('');
var utilisateur = $(this).val();
if (utilisateur != "") {
$.ajax({
type: 'GET',
url: 'recherche.php',
data: 'user=' + encodeURIComponent(utilisateur),
success: function(data) {
if (data != "") {
$('#resultat').append(data);
} else {
document.getElementById('resultat').innerHTML =
"<div >Aucun resultat</div>";
}
}

});
}

});
});
</script>

<?php
session_start();
$db = new PDO('mysql:host=localhost;dbname=gestpartres', 'root', '');
if (isset($_GET['user'])) {
$user = (string)trim($_GET['user']);
$etudiants = $db->query(
"SELECT *
FROM module m JOIN classe c on m.enres=c.enres
where id_classe=1 and nom_module LIKE '%$user%'
LIMIT 6"
);
$etudiants = $etudiants->fetchAll();
foreach ($etudiants as $r) { ?>
<a href="detailcoursl1.php?id_module=<?= $r['id_module'] ?>"
style="color:black">
<div style=" background-color:white; font-size:150%;">
<?= $r['nom_module'] ?>
</div>
</a>
<?php
}
}

You might also like