Outer loop not working in Nested-While-Loop

I have three tables blogs, comments and replies.

I have the blog_id primary key in the blogs tables, comment_id primary key in the comments tables, and reply_id primary key in the replies tables.

In the blogs table I have one column named as-

blog_id         int(11)

In the comments table I have the following columns-

comment_id         int(11),
comment_viewer_id  int(11),
comm_blog_id       int(11),
comment_message    longtext,
comment_on         datetime

In the replies table I have the following columns-

reply_id         int(11),
reply_viewer_id  int(11),
reply_blog_id    int(11),
reply_comm_id    int(11),
reply_message    longtext,
reply_on         datetime

Suppose I have a blog_id = "2", and
I have a comment_id = "5".

The query which I have used to fetch the comment_message is as follows:

SELECT * FROM `comments` 
INNER JOIN `blogs` 
ON comments.comm_blog_id = blogs.blog_id 
WHERE comments.comm_blog_id = '2' 
ORDER BY comments.comment_on 
DESC

The query which I have used to fetch the reply_message is as follows:

SELECT * FROM `replies` 
INNER JOIN `blogs` 
INNER JOIN `comments` 
ON replies.reply_blog_id = blogs.blog_id 
AND replies.reply_comm_id = comments.comment_id 
WHERE replies.reply_blog_id = '2' 
AND replies.reply_comm_id = '5' 
ORDER BY replies.reply_on 
DESC

The query that I have used to fetch the data from the database uses a while-loop inside the while-loop(i.e. Nested-While-Loop) inside the PHP as follow:

$sql_comm = "SELECT * FROM `comments` INNER JOIN `blogs` ON comments.comm_blog_id = blogs.blog_id WHERE comments.comm_blog_id = '2' ORDER BY comments.comment_on DESC";
            $result = mysqli_query($conn, $sql_comm);

            while ($row = mysqli_fetch_assoc($result)) {
                $comment_message = $row["comment_message"];

                echo '
                    <div class="comment_container">
                        <div class="comment_box">
                            <div class="comment_card">
                                <div class="user_details">
                                    <div class="user_dp">
                                        <img src="../img/users_img/black-soil.jpg" alt="">
                                    </div>
                                    <div class="user_name">
                                        <h3>@hello viewer</h3>
                                    </div>
                                </div>
                                <p>'.$comment_message.'</p>
                                <div class="comment_footer">
                                    <div class="like">
                                        <button type="submit">
                                            <i class="fa-regular fa-thumbs-up"></i>
                                        </button>
                                        <p>50</p>
                                    </div>
                                    <div class="dislike">
                                        <button type="submit">
                                            <i class="fa-regular fa-thumbs-down"></i>
                                        </button>
                                        <p>5</p>
                                    </div>
                                    <div class="reply">
                                        <button type="submit">
                                            <p>reply</p>
                                        </button>
                                        <p>0</p>
                                    </div>
                                </div>
                            </div>';


                            $sql_reply = "SELECT * FROM `replies` INNER JOIN `blogs` INNER JOIN `comments` ON replies.reply_blog_id = blogs.blog_id AND replies.reply_comm_id = comments.comment_id WHERE replies.reply_blog_id = '2' AND replies.reply_comm_id = '5' ORDER BY replies.reply_on DESC";
                            $result = mysqli_query($conn, $sql_reply);

                            while ($row = mysqli_fetch_assoc($result)) {
                            $reply_message = $row["reply_message"];
                                echo '
                                    <div class="comment_box">
                                        <div class="comment_card">
                                            <div class="user_details">
                                                <div class="user_dp">
                                                    <img src="../img/users_img/black-soil.jpg" alt="">
                                                </div>
                                                <div class="user_name">
                                                    <h3>@hello viewer</h3>
                                                </div>
                                            </div>
                                            <p>'.$reply_message.'</p>
                                            <div class="comment_footer">
                                                <div class="like">
                                                    <button type="submit">
                                                        <i class="fa-regular fa-thumbs-up"></i>
                                                    </button>
                                                    <p>50</p>
                                                </div>
                                                <div class="dislike">
                                                    <button type="submit">
                                                        <i class="fa-regular fa-thumbs-down"></i>
                                                    </button>
                                                    <p>5</p>
                                                </div>
                                                <div class="reply">
                                                    <button type="submit">
                                                        <p>reply</p>
                                                    </button>
                                                    <p>0</p>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                ';
                            }
                        ';
                    </div>
                </div>';
            }

Using the above query I have get multiple replies_comment but I have didn’t get multiple comment_message.

I want the result just like this-

Blog-1-Comment-1
   Blog-1-Comment-1-Reply-1
   Blog-1-Comment-1-Reply-2
   Blog-1-Comment-1-Reply-3

Blog-1-Comment-2
   Blog-1-Comment-2-Reply-1
   Blog-1-Comment-2-Reply-2

Blog-1-Comment-3

Blog-1-comment-4

Comment database table

Replies database table

I want the result just like this-

Blog-1-Comment-1
   Blog-1-Comment-1-Reply-1
   Blog-1-Comment-1-Reply-2
   Blog-1-Comment-1-Reply-3

Blog-1-Comment-2
   Blog-1-Comment-2-Reply-1
   Blog-1-Comment-2-Reply-2

Blog-1-Comment-3

Blog-1-comment-4

New contributor

Renuka sharma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật