I am coding a message board script and have just started work on the template system.
function templates($templatename,$topicID)
{
$template_query = mysql_query("SELECT name,html FROM templates WHERE (name='$templatename')");
$template = mysql_fetch_array($template_query);
$templatex=$template['html'];
$gettopic_query = mysql_query("SELECT TopicName FROM topics WHERE (ID=$topicID)");
$gettopic = mysql_fetch_array($gettopic_query);
$getpost_query = mysql_query("SELECT Name,Post FROM posts WHERE (TopicID='$topicID')");
while ($getpost = mysql_fetch_array($getpost_query)) {
$find_var=array("%topicname%", "%author%", "%postbody%");
$rplc_var=array("$gettopic[TopicName]","$getpost[Name]","$getpost[Post]");
}
$new_template=str_replace($find_var,$rplc_var,$templatex);
print $new_template;
}
function viewpost($topicID)
{
$topic_query = mysql_query("SELECT TopicName FROM topics WHERE (ID=$topicID)");
$topic = mysql_fetch_array($topic_query);
templates(viewthread_head_subject,$topicID);
$post_query = mysql_query("SELECT * FROM posts WHERE (TopicID='$topicID')");
while ($post = mysql_fetch_array($post_query)) {
templates(viewthread_post_body,$topicID);
}
templates(viewthread_post_foot,$topicID);
}
Those are my functions for the template system. and view post script.
My problem is that as you can see here: http://www.agent-penguin.net/penguinbb0.1/test/test.php?topicID=1
it only shows the last result in the mysql query.
I don't know how to get it to show EVERY result in order, instead of just the last 1.
The person who tried to help had no clue what he was talking about.