1

ID の後に foreach ループの結果をソートすることは可能ですか? 最初に最高のIDなど...記事なので、最高のID(最新)を最初にしたい:)

私のコード:

include_once('includes/connection.php');
include_once('includes/article.php');

$article = new Article;
$articles = $article->fetch_all();



?>
<html>
    <head>
        <title>CMS</title>
        <link rel="stylesheet" href="assets/style.css" />
    </head>

    <body>
        <div class="container">
            <a href="index.php" id="logo">CMS</a>

            <ol>
                <?php foreach ($articles as $article) { ?>
                    <li>
                        <a href="article.php?id=<?php echo $article['article_id']; ?>">
                            <?php echo $article['article_title']; ?>
                        </a>

                        - <small>
                            Posted <?php echo date('l jS', $article['article_timestamp']); ?>
                        </small>
                    </li>
                <?php } ?>
            </ol>

            <br />

            <small><a href="admin">Admin Login</a></small>

        </div>
    </body>
</html>
4

1 に答える 1