I am trying to implement a comment system, but it returns the post as many times the comment of that post exists.
Please help me with the code to solve out this.
Thank you.
The sample I have is like:
<?php
include('connect.php');
?>
<form method="post">
Subject<br>
<input type="text" name="subject"><br><br>
Message<br>
<textarea name="text"></textarea>
<br>
<input type="submit" name="poster" value="Post">
</form>
<?php
if (isset($_POST['poster'])) {
$subject=$_POST['subject'];
$message=$_POST['text'];
$post=mysql_query("insert into comment (titles, message) values ('$subject', '$message')");
if ($post) {
echo "Data got";
}else{
echo "Failed";
echo mysql_error();
}
}
$select=mysql_query("SELECT comment.id, comment.titles, comment.message, replies.id, replies.idno, replies.subject, replies.textfile from comment left JOIN replies ON comment.id=replies.id ;");
while ($row=mysql_fetch_array($select)) {
echo "<b>".$row['titles']."</b><br>";
echo $row['message']."<br>";
echo "<a href=\"edit.php?id=$row[id]\">Reply</a><br>";
echo "<font color='green'><ul>".$row['textfile']."</ul></font><br><br>";
}
?>
But it returns:
Thank you.