Php: Archives system like blog

大憨熊 提交于 2019-12-02 09:32:46

Assuming that dateNews is the month (which it appears to be), then you've almost got it. You just need to also select the count of each grouping and then display it.

<?php
    $q = $db->query("SELECT dateNews, COUNT(*) AS newsCount FROM news GROUP BY dateNews");

    while($data = $q->fetch()){
        $dateMonth= $data['dateNews'];
        echo "<a href='#''><p>".strftime('%B %Y', strtotime($dateMonth))." (" . $data['newsCount'] . ")</span></p></a>";
    }                   
?>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!