Hi
I am building a simple discussion board. I need to keep to some counts of posts and other things as this function is iterated through. How do I keep the value of the count in scope and increment it and also return more than one variable?
public function getPosts($postId)
{
$posts = mysql_query("SELECT * FROM discussion WHERE id='$postId'");
while ($post = mysql_fetch_array($posts)) {
$output .= "<div id=\"post{$post["id"]}\" class=\"post\">
<div class=\"postHeader\">
<div class=\"postAuthor\"><strong>{$post["author"]}</strong> wrote</div>
<div class=\"postTimestamp\"><span style=\"color:gray;\">" . readableTime::getTime($post["timestamp"]) . "</span></div>
<div class=\"clearFix\"></div>
</div>
<div class=\"postContent\">
<div class=\"postMessage\">{$post["body"]}</div>
<div class=\"postActions\">
<div class=\"postDetails\">
<div class=\"postNumber\">Post #1</div>
<div>1 reply</div>
</div>
<div><a href=\"#\">Reply to Post</a></div>
<div><a href=\"#\">Delete Post</a></div>
<div><a href=\"#\">Edit Post</a></div>
<div><a href=\"#\">Report Post</a></div>
</div>
<div class=\"clearFix\"></div>
</div>
</div>";
}
$subPosts = mysql_query("SELECT id FROM discussion WHERE parentId='$postId'");
while ($subPost = mysql_fetch_array($subPosts))
$output .= discussionBoard::getPosts($subPost["id"]);
return $output;
}