Hi Everyone;
i have a page where users can post and comment for each post.
Problem is when i click Comment button, the list of comments are shown only for one post which is on the first and also finding a way to list the comments related to the specific post.
The code to Show Posts are as follows:
showposts.php
[php]
<?php
include 'connection.php';
?>
<?php
$sql = "SELECT * FROM posts ORDER BY id DESC";
$result = mysqli_query($connect, $sql);
while($row = mysqli_fetch_array($result)){
?>
<?php echo $row['username']?> <?php echo $row['posteddate']?>
<?php echo $row['postedtime']?> |
|
||
<?php echo $row['subject']?> | |||
<?php echo $row['pubdata']?> |
Like |
Comment
|
Share | <?php echo " " . "Delete" . " "?> |
<?php
/*WHERE postid='$postid'*/
$resultcmt=mysqli_query($connect, "SELECT * FROM comments ORDER BY cmtid DESC");
while($rowcmt=mysqli_fetch_array($resultcmt)){
?>
<?php }?>
|
|||||
<?php echo $rowcmt['comment'];?> |
<?php }?>
Post | |
|
<?php } ?> [/php]
The code for Posting Comments are as follows;
commentpost.php
[php]
Below is the code i used to show and Hide comments ;
function showcomment() {
var x = document.getElementById("comment");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
}
Please Help