Bonjour, je suis un débutant en php. Voila je veux créer un bouton de recherche qui affichera les information de ma bd pour cela voici mon code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>IPW</title>
<meta content="" name="description">
<meta content="" name="keywords">
<!-- Favicons -->
<!-- <link href="assets/img/favicon.png" rel="icon">
<link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon"> -->
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans%3A300%2C300i%2C400%2C400i%2C600%2C600i%2C700%2C700i%7CRaleway%3A300%2C300i%2C400%2C400i%2C500%2C500i%2C600%2C600i%2C700%2C700i%7CPoppins%3A300%2C300i%2C400%2C400i%2C500%2C500i%2C600%2C600i%2C700%2C700i" rel="stylesheet">
<!-- Vendor CSS Files -->
<link href="assets/vendor/aos/aos.css" rel="stylesheet">
<link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
<link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
<link href="assets/vendor/glightbox/css/glightbox.min.css" rel="stylesheet">
<link href="assets/vendor/remixicon/remixicon.css" rel="stylesheet">
<link href="assets/vendor/swiper/swiper-bundle.min.css" rel="stylesheet">
<!-- Template Main CSS File -->
<link href="assets/css/style.css" rel="stylesheet">
</head>
<body>
<?php
require 'include/navbar.php';
?>
<main id="main">
<!-- ======= Breadcrumbs ======= -->
<section class="breadcrumbs">
<div class="container">
<div class="d-flex justify-content-between align-items-center">
<h2>Consulter le statut de votre enfant</h2>
</div>
</div>
</section><!-- End Breadcrumbs -->
<section class="inner-page">
<section class="row">
<div class="col-12 col-md-9">
<h1 class="text-center">Veillez saisir votre nom complet</h1>
<div class="mg-auto">
<?php
if (isset($_GET['mot_cles']) AND !empty($_GET['mot_cles'])) {
require_once('include/config.php');
$recherche = htmlspecialchars($_GET['mot_cles']);
$req = $db->query('SELECT * FROM eleves WHERE NOMPARENT LIKE "%'.$recherche.'%" ORDER BY IDELEVE DESC');
$nb = $req->rowCount();
@$affichage="oui";
}
?>
<form name="recherche" method="get" action="">
<div class="input-group">
<input type="text" name="mot_cles" placeholder="Votre nom..." class="form" autocomplet="off"/>
<div class="input-group-append">
<input type="submit" name="valider" value="Rechercher" />
</div>
</div>
</form>
<?php
if (@$affichage=="oui") {
if ($nb > 0) {
?>
<div id="resultats">
<div id="nbr"><?= $nb." ".($nb>1?"Résultats trouvés":"Résultat trouvé") ?></div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th class="text-center">
<?php if ($nb>1) {
echo "Matricules";
}else{
echo "Matricule";
} ?>
</th>
<th>
<?php if ($nb>1) {
echo "Noms";
}else{
echo "Nom";
} ?>
</th>
<th>
<?php if ($nb>1) {
echo "Prénoms";
}else{
echo "Prénom";
} ?>
</th>
<th>
<?php if ($nb>1) {
echo "Sexes";
}else{
echo "Sexe";
} ?>
</th>
</tr>
</thead>
<tbody>
<?php
while ($enfant=$req->fetch()) {
?>
<tr>
<td class="text-center"><?php echo $enfant['MATRICULE'] ?></td>
<td><?php echo $enfant['NOM'] ?></td>
<td><?= $enfant['PRENOM'];?></td>
<td class="td-actions text-right"><?= $enfant['SEXE'];?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
<?php
}else{?>
<tr>
<td row=3 class="text-center">Aucun resultat trouvé</td>
</tr>
<?php
}
}
?>
</div>
</div><!--End first column-->
<div class="col-12 col-md-3">
<ul class="list-group">
<li class="list-group-item list-group-item-action">
<a href="#">Catégorie 1</a>
</li>
<li class="list-group-item list-group-item-action">
<a href="#">Catégorie 2</a>
</li>
<li class="list-group-item list-group-item-action">
<a href="#">Catégorie 3</a>
</li>
<li class="list-group-item list-group-item-action">
<a href="#">Catégorie 4</a>
</li>
<li class="list-group-item list-group-item-action">
<a href="#">Catégorie 5</a>
</li>
</ul>
</div><!--End second column-->
</section>
</section>
</main><!-- End #main -->
<?php
require 'include/pied_page.php';
?>
<a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
<!-- Vendor JS Files -->
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<!-- Template Main JS File -->
<script src=""></script>
</body>
</html>
je réussis bien a avoir le nombre d'elements trouvés mais j'ai une erreur undefined index et je ne comprend pas l'erreur.
Besoin d'aide svp.
Afficher la suite