Add article page

This commit is contained in:
2024-02-22 09:42:37 +01:00
parent 26a0a7488c
commit 06feb93095
4 changed files with 69 additions and 8 deletions

20
lib/newsarticle.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
function getNewsArticles() :array
{
global $mysqli;
$articles = [];
if (isLoggedIn()) {
$result = $mysqli->query("SELECT NewsArticles.ID, NewsArticles.WrittenAt, NewsArticles.WrittenBy, NewsArticles.Title, NewsArticles.Body, NewsArticles.FileList Users.Nickname FROM NewsArticles INNER JOIN Users ON NewsArticles.WrittenBy = Users.ID; ");
// Check if the query executed Successfully
if ($result) {
while ($row = $result->fetch_assoc()) {
$articles[] = $row;
}
}
}
return $articles;
}