博客档案中的统一链接

时间:2014-10-11 02:33:49

标签: php mysqli blogs archive

我制作了一个博客档案及其工作,但我的链接有问题。每当我试图点击任何一个标题时,它总是指示我到我的第一篇文章,我的最新帖子部分,另一方面工作得很好。我没有找到解决问题的正确方法。

2014
十月
简历提示
九月
所有在一天的工作中 八月
赢得Windows Phone
六月
健康的工作场所 可以
办公室管理的艺术 的 2013
四月
那份工作面试 的 2012
可以
随时待命
免费研讨会

这是我的代码:

    <div class="side_container">
        <h2 class="simple_title">Archives</h2>
            <div style="padding-left: 20px; padding-bottom: 18px;">

            <?php 
            include("connection/connect.php"); 

            $select_posts = "SELECT post_id,post_date,post_title, YEAR(post_date) AS YEAR, MONTH(post_date) AS MONTH";

            $run_posts = mysqli_query($con, $select_posts);

            while ($row = mysqli_fetch_array($run_posts)){


                $postMonth= $row['post_date'];
                $post_id = $row['post_id'];
                $post_title = $row['post_title'];
                $post_date = $row['post_date'];

            $sql2 = mysqli_query($con, "SELECT DISTINCT YEAR(post_date) FROM posts ORDER BY YEAR(post_date) DESC");

            $archive = "<ul>"; 
            while($row2 = mysqli_fetch_assoc($sql2)){ 
                foreach ($row2 as $year) {  
                $archive .= "<li><b>$year</b><ul>"; 
                    $sql3 = mysqli_query($con, "SELECT DISTINCT MONTH(post_date) FROM posts WHERE YEAR(post_date)='$year' ORDER by MONTH(post_date) DESC");

                    while($row3 = mysqli_fetch_assoc($sql3)){ 
                        foreach ($row3 as $month) {  

                            $archive .= "<li><div><a href='#' style='text-transform: none; color:#333; font-size: 14px;'>".date('F', mktime(0, 0, 0, $month, 1, 2000))."</a><ul>"; 
                            $sql4 = mysqli_query($con, "SELECT * FROM posts WHERE MONTH(post_date)='$month' AND YEAR(post_date)='$year' ORDER by post_date DESC");

                            while($row4 = mysqli_fetch_assoc($sql4)){ 
                                $title2 = $row4['post_title'];                                 $archive .=  "<div><ul><li><a style='text-transform: none; color:#333; font-size: 14px;'   href='pages.php?id={$post_id}'>".$title2."</a></li></ul></div>";
                            } 
                        }  
                        $archive .= "</ul></div></li>"; 
                    } 
                $archive .= "</ul></li>"; 
                }  
            } 
            $archive .= "</ul>"; 
            echo $archive; 
            }
            ?>
</div>

0 个答案:

没有答案