diff --git a/Assets/functions.php b/Assets/functions.php index 77a79eb..3ef2ad7 100644 --- a/Assets/functions.php +++ b/Assets/functions.php @@ -19,11 +19,14 @@ function connectBDD($domain, $user, $password, $db) } } -function getActus($bdd) +function getActus($bdd, $limit) { - $results = mysqli_query($bdd, "SELECT * FROM `actus` ORDER BY `id` LIMIT 4"); - $return = []; - return $results; + $results = mysqli_query($bdd, "SELECT * FROM actus ORDER BY id DESC LIMIT ".$limit); + $actus = []; + while ($row = mysqli_fetch_assoc($results)) { + $actus[] = $row; + } + return $actus; } function validateCSRFToken($csrf_server, $csrf_client) @@ -227,13 +230,13 @@ function updateEventTitle($bdd, $eventid, $titre){ return $success; } -function updateEventImage($bdd, $eventId, $newFileName){ +function updateEventImage($bdd, $eventId, $image){ $stmt = mysqli_prepare( $bdd, "UPDATE evenements SET couverture = ? WHERE id = ?" ); - mysqli_stmt_bind_param($stmt, "si", $newFileName, $eventId); + mysqli_stmt_bind_param($stmt, "si", $image, $eventId); mysqli_stmt_execute($stmt); $success = mysqli_stmt_affected_rows($stmt) >= 0; @@ -254,13 +257,13 @@ function getSpecificActus($bdd, $id) return $return; } -function updateActuImage($bdd, $actuId, $newFileName){ +function updateActuImage($bdd, $actuId, $image){ $stmt = mysqli_prepare( $bdd, "UPDATE actus SET image = ? WHERE id = ?" ); - mysqli_stmt_bind_param($stmt, "si", $newFileName, $actuId); + mysqli_stmt_bind_param($stmt, "si", $image, $actuId); mysqli_stmt_execute($stmt); $success = mysqli_stmt_affected_rows($stmt) >= 0; @@ -325,4 +328,17 @@ function deleteActu($bdd, $eventId){ $req->bind_param("i", $eventId); $req->execute(); return $req->affected_rows > 0; +} + +function createActu($bdd, $titre, $actu, $date, $idSite){ + + $stmt = mysqli_prepare( + $bdd, + "INSERT INTO actus (titre, actu, date, idSite) VALUES (?, ?, ?, ?)" + ); + mysqli_stmt_bind_param($stmt, "sssi", $titre, $actu, $date, $idSite); + mysqli_stmt_execute($stmt); + $actuId = mysqli_insert_id($bdd); + mysqli_stmt_close($stmt); + return $actuId; } \ No newline at end of file diff --git a/admin/createActu.php b/admin/createActu.php new file mode 100644 index 0000000..d2f5517 --- /dev/null +++ b/admin/createActu.php @@ -0,0 +1,169 @@ + + + + + +
+ +