diff --git a/admin123/admin.php b/admin123/admin.php
index b032724..d995a71 100644
--- a/admin123/admin.php
+++ b/admin123/admin.php
@@ -17,6 +17,11 @@ if (isset($_SESSION['user'], $_SESSION['password'])) {
header('Location: index.php');
}
+if (isset($_POST['delete'])) {
+ $id = $_POST['delete'];
+
+ deleteProject($id);
+}
if (isset($_POST['project-name'], $_POST['description-project'])) {
$projectName = trim($_POST['project-name']);
@@ -35,6 +40,26 @@ if (isset($_POST['project-name'], $_POST['description-project'])) {
}
}
+
+$limit = 15;
+
+$numberOfPages = getProjectNumberOfPages($limit);
+
+if (isset($_GET['page'])) {
+ $page = (int) $_GET['page'];
+} else {
+ $page = 1;
+}
+
+if ($page > $numberOfPages) {
+ $page = 1;
+}
+
+$projects = getProjects($page, $limit);
+$pager = getProjectsPager($page, $numberOfPages);
+
+$prev = $page - 1;
+$next = $page + 1;
?>
@@ -42,7 +67,7 @@ if (isset($_POST['project-name'], $_POST['description-project'])) {
-
+
Mon super portfolio
@@ -71,6 +96,47 @@ if (isset($_POST['project-name'], $_POST['description-project'])) {
Liste des projets
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1): ?>
+
+
+
diff --git a/admin123/index.php b/admin123/index.php
index 6860007..5e75953 100644
--- a/admin123/index.php
+++ b/admin123/index.php
@@ -21,7 +21,6 @@ if (isset($_POST['user'], $_POST['password'])) {
login($user, $password);
}
}
-
?>
@@ -33,14 +32,13 @@ if (isset($_POST['user'], $_POST['password'])) {
-Ici, c'est l'administration, c'est ici qu'on trouve toute l'administration.
+Ici, c'est l'administration, c'est ici qu'on trouve toute l'administration.
diff --git a/lib/project.php b/lib/project.php
index de98e87..130e16b 100644
--- a/lib/project.php
+++ b/lib/project.php
@@ -7,7 +7,7 @@
* @param int $limit Nombre de projets par page
* @return array Les projets
*/
-function getProjects($page = 1, $limit = 5, $orderBy = 'date', $orderBySens = 'ASC')
+function getProjects($page = 1, $limit = 5, $orderBy = 'id', $orderBySens = 'DESC')
{
if (!is_integer($page)) {
throw new InvalidArgumentException('The argument "page" must be an integer.');
@@ -89,6 +89,24 @@ function createProject($name, $description, DateTime $date)
]);
}
+/**
+ * Supprime un nouveau projet
+ *
+ * @param string $id id du projet
+ */
+function deleteProject($id)
+{
+ $pdo = getDatabaseConnection();
+
+ $query = $pdo->prepare(
+ 'DELETE FROM project WHERE id=:id'
+ );
+
+ $query->execute([
+ ':id' => $id
+ ]);
+}
+
/**
* @param int $maxPerPage Nombre de projets par page
* @return int Le nombre de pages