Member Avatar for සශික

I'm developing some kind of web application simillar to forum. I want to show comments under which it belongs to. I currently used bootstrap, php, mysql for this. Here I post my code....

<div class="col-md-7">
                        <div class="col-md-12">
                         <form  action="insert_post.php" method="post">
                            <div class="input-group">
                            <p><b>You Are Posting As : </b></p><h4><span class="label label-default"><?php echo $_SESSION['username'] ?></span></h4>
                            <textarea class="form-control" rows="2" cols="100" name="postcomment"></textarea>
                             </div><br>
                             <div class="input-group">
                                 <button type="submit" class="btn btn-success btn-sm" name="btn_post">Upload</button>
                                 <button type="reset" class="btn btn-danger btn-sm">Clear</button>
                             </div>
                          </form>  
                        </div>
                        <div class="col-md-12">
                        <font size="4"><span class="label label-default">Your Most Recent Posts : </span></font>
                        <?php

                        echo '<div class="container-fluid">';
                        //echo '<table>';
                        while($row=mysqli_fetch_array($result))
                        {   
                            $post_id=$row['post_id'];
                             $result2= mysqli_query($con,"SELECT * FROM `comment` WHERE post_id='.$post_id.' ORDER BY `comment`.`t_stamp` DESC")or die("User Error : ".mysqli_error());
                            //echo $post_id;
                             echo' <br>
                            <div class="container-fluid" style="border-radius: 10px;">
                                <div class="col-md-12">
                                    <div class="col-md-12" style="background-color:#f0f0f5;">
                                        <font size="3"><b>By :</b> '.$row['user'].'</font>
                                        <font size="3"><p align="left"><b>@ : </b><i>'.$row['t_stamp'].'</i></p></font>
                                    </div>
                                    <div class="col-md-12" style="background-color:#e6f2ff;">
                                        <font size="4"><p align="justify">'.$row['description'].'</p></font>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                        <form  action="insert_comment.php" method="post">
                                         <input type="hidden" name="post_identify" value="'.$row['post_id'].'">
                                                    <textarea class="form-control" style="width:600px;" placeholder="Type Your Response" name="comment"></textarea>
                                        <div class="input-group">
                                        <button type="submit" class="btn btn-primary btn-xs" name="btn_comment">Response</button>
                                        </div>
                                        </form>
                                        </div>
                                <div class="col-md-12">';
                             while($row2=mysqli_fetch_array($result2))
                                 {
                                  echo '
                                    <div class="col-md-3" style="background-color:#f0f0f5;">
                                     username<font size="2"><b> '.$row2['user'].'</b></font>
                                    </div>
                                    <div class="col-md-9" style="background-color:#f0f0f5;">
                                    comment<font size="3">'.$row2['comment'].'</font>
                                    </div>'; }
                                 echo'</div>
                             </div><br>'; 
                        }
                        echo '</div>';
                        ?>
                        </div>
                    </div>

The problem is, it's not showing comments under posts which had comments. I checked post and comment tables. There are many records which refering to posts....
So I want your help to identify why my error is occure :)

Member Avatar for diafol

This is a confusing snippet. We have unknown variables such as $row and $result.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.