Here is a tid-bit of the reading page:
$text_count = substr_count($template_content, "[TextArea");
//////////////////////////////////////////////////////
for ($i_text=1; $i_text<($text_count + 1); $i_text++) {
$query_text = "select * from text where text_id = '".$master_id."' and text_num = '".$i_text."'";
$result_text = mysql_query($query_text);
$row_text = mysql_fetch_array($result_text);
$text_text[$i_text] = $row_text[text_text];
$text_text[$i_text] = stripslashes($text_text[$i_text]);
$template_content = ereg_replace("\[TextArea".$i_text."\]", $text_text[$i_text]."", $template_content);
}
This one finds all the [TextArea#] tags in the template. Then pulls info from a linked table based on the $query_text line above, and puts it in [TextArea#]'s place. But you could do this with anything, like this:
$template_content = function();
// instead of //
$template_content = ereg_replace("\[TextArea".$i_text."\]", $text_text[$i_text]."", $template_content);
Then you have the results of function() in the place of [TextArea#] and you can get rid of all that ugly query code in the for loop...
Does that help? Let me know if you need more than this.