如何在PHP中创建存档?

时间:2014-03-29 12:48:04

标签: php html mysql css archive

我想显示一个存档页面。 我想将年份作为父类别,然后将月份作为子项,然后将帖子/日期显示为页面中的最后一个子类别。我试过谷歌搜索。

我已成功获得年度和月份,但不超过这个。

我的代码如下:

<?php
$con=mysqli_connect($host, $user, $pass, $dbname);

$con=mysqli_connect("localhost","root","","ddblog");
// Check connection
if (mysqli_connect_errno()){
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM tblarchive group by aYear order by ayear desc ");

while($row = mysqli_fetch_array($result)){    
    echo "<div class='w_100 mb10' ><h2 class='heading3 bb2' style='padding-bottom: 10px;'>".$row['aYear']."</h2>";

    $result2 = mysqli_query($con,"SELECT * FROM tblarchive where aYear=".$row['aYear']."");

    while($row2 = mysqli_fetch_array($result2)){
        echo"<div class='w_100 fl'><h3 class='heading3'>".$row2['aMonth'].
            "</h3><div class='para'><ul class='listim'><li><a href=".$row2['aLink'].
            " class='co1'>".$row2['aDesc']."</a></li></ul></div></div> ";    
    }
    echo  "<a href='#' class='tn colrong2'>See More</a>";
 }

mysqli_close($con);
?>

Archive

0 个答案:

没有答案