Cofem/lib/newsarticle.php
2024-02-22 09:42:37 +01:00

20 lines
637 B
PHP

<?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;
}