Update file news.php

This commit is contained in:
Jan BELLON 2024-03-08 19:08:48 +00:00
parent d50e8d9530
commit 4f1e3c673f

View File

@ -48,14 +48,14 @@ if (filter_var($_GET['article'], FILTER_VALIDATE_INT)) {
if ($article == "") { if ($article == "") {
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass); $bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
$search = isset($_GET['search']) ? "'%" . htmlspecialchars($_GET['search']) . "%'" : "'%%'"; $search = isset($_GET['search']) ? "'%" . htmlspecialchars($_GET['search']) . "%'" : "'%%'";
$req = $bdd->prepare("SELECT ID, titre, date FROM articles WHERE titre LIKE :search AND classification <= :accreditation ORDER BY date DESC"); $req = $bdd->prepare("SELECT ID, titre, date FROM articles WHERE (titre LIKE :search OR ID LIKE :search) AND classification <= :accreditation ORDER BY date DESC");
$req->bindParam(":search", $search); $req->bindParam(":search", $search);
$req->bindParam(":accreditation", $_SESSION['accreditation']); $req->bindParam(":accreditation", $_SESSION['accreditation']);
$req->execute(); $req->execute();
$resultat = $req->fetchAll(PDO::FETCH_ASSOC); $resultat = $req->fetchAll(PDO::FETCH_ASSOC);
echo "<h1>Dernières news du Club</h1>"; echo "<h1>Dernières news du Club</h1>";
echo "<form action='' method='get'><input type='text' placeholder='Rechercher un article' name='search'></form>"; echo "<form action='' method='get'><input type='text' placeholder='Article' name='search'><input type=='submit' value='Rechercher'></form>";
if ($resultat) { if ($resultat) {
foreach($resultat as $row) { foreach($resultat as $row) {