Update file editpage.php

This commit is contained in:
Jan BELLON 2024-03-11 15:24:48 +00:00
parent 371dd5b1d7
commit 6fc95c21b5

View File

@ -164,9 +164,17 @@ if(isset($fichier)) {
} }
echo "</div></div><div>"; echo "</div></div><div>";
echo "<div><h2>Articles</h2></div>"; echo "<div><h2>Articles</h2></div>";
echo "<form action='' method='get'><input type='text' placeholder='Article' name='search'><input type='submit' value='Rechercher'></form>";
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass); $bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
$req = $bdd->prepare("SELECT ID, titre, date FROM articles WHERE classification <= :accreditation ORDER BY date DESC LIMIT 10"); $condition = ""
if(isset($_GET['search'])) {
$search = "%" . htmlspecialchars($_GET['search']) . "%";
$condition = " AND (titre LIKE " . $search . " OR ID LIKE " . $search;
}
$req = $bdd->prepare("SELECT ID, titre, date FROM articles WHERE classification <= :accreditation :condition ORDER BY date DESC LIMIT 10");
$req->bindParam(":accreditation", $_SESSION['accreditation']); $req->bindParam(":accreditation", $_SESSION['accreditation']);
$req->bindParam(":condition", $condition);
$req->execute(); $req->execute();
$resultat = $req->fetchAll(PDO::FETCH_ASSOC); $resultat = $req->fetchAll(PDO::FETCH_ASSOC);