Hi,
I have code so that users can make comments on a page, they have a choice to have their name displayed or be anonymous. I want to order the comments by the date they were made, and display the name or 'anonymous poster' if they selected anonymous.
So I have this code which grabs everything into an array, but the if statement within the array is not working, in testing, when I select anonymous the page still displays the name of the user. What is the best way around this?
The following code is where I am stuck:
echo "<h3>Comments for this article:</h3>";
while($fetch=mysql_fetch_array($query)) {
$anonymous=$fetch['anonymous'];
if ($anonymous===true){
echo "<p>".$fetch['comment']."<br/><sub><b>Comment by: </b>'Anonymous Poster'</sub><hr /><p>";
}
else{
echo "<p>".$fetch['comment']."<br/><sub><b>Comment by: </b>".$fetch['userid']."</sub><hr /><p>";
}
}
Thanks,
G