First commit

This commit is contained in:
2025-09-11 11:25:49 +02:00
commit 2a1804109b
19 changed files with 256 additions and 0 deletions

20
modele/livres.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
include("../donnees/connexion.php");
// Ajout dun livre
function addLivre() {
include("../donnees/connexion.php");
if (!empty($_POST['categorie']) && !empty($_POST['titre']) && !empty($_POST['auteur']) && !empty($_POST['annee'])) {
$stmt = $db->prepare("INSERT INTO livres (categorie, titre, auteur, annee) VALUES (?, ?, ?, ?)");
$stmt->execute([$_POST['categorie'], $_POST['titre'], $_POST['auteur'], $_POST['annee']]);
}
}
// Récupération des livres
function getLivres() {
include("../donnees/connexion.php");
$stmt = $db->query("SELECT livres.*, categories.nom FROM livres INNER JOIN categories ON categories.id = livres.categorie");
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
?>