博客档案中的统一链接

I made a blog archives and its working, yet i have problems with the link. Whenever I try to click on any of the title, it always directs me to my first post, my Latest Post Section, on the other hand is working great. I don't get the right approach to fix the problem.

2014
October
Resume Tips
September
All in a Day's Work
August
Win a Windows Phone
June
A Healthy Workplace
May
The Art of Office Management
2013
April
Ace That Job Interview
2012
May
Always on Time
Free Seminar

Here is my code:

    <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>