hi,
i have a page i want to include into one of my pages, which forms a template
but when i include it, everything is outputted, before anything else is, i need the include not to output anything until the template variable is outputted
i found that adding each line of the include into a variable works, but i would need to do this for several pages
here is my page
<?
session_start();
include ("includes/template.inc");
include ("includes/functions.inc");
include ("includes/common.inc");
$sql = "SELECT * FROM `pageinfo` WHERE `page`='".$_SERVER['SCRIPT_NAME']."'";
$qry = mysql_query($sql, $conn) or die(mysql_error());
$row = mysql_fetch_array($qry);
$index = $row['update'];
$sql = "SELECT * FROM `update` WHERE `id` = '$index' LIMIT 0,1";
$query = mysql_query($sql, $conn) or die(mysql_error());
$test = mysql_fetch_array($query);
if ($test['updating'] == '1') {
$url = "http://www.theutherfish.com/update.php";
die(Header('Location: '. $url));
}
$tpl = new Template("templates", "remove");
$tpl -> set_file(array(
"header" => "header.tpl",
"footer" => "footer.tpl",
"style" => "style.tpl",
"body" => "body.tpl",
"message" => "message.tpl"));
$menuitem = $row['menu'];
$tpl -> set_var(ADVERT, ad_banner());
$tpl -> set_var(MENU, menu($menuitem));
$title = $row['pagename'];
if($title=='' || !isset($title)) {
$tpl -> set_var(TITLE, "theutherfish.com - [Home] - the best thing since sliced bread");
}
else {
$tpl -> set_var(TITLE, "theutherfish.com - [".ucwords($title)."] - the best thing since sliced bread");
}
$location = $row['pagename'];
if($location=='' || !isset($location)) {
$tpl -> set_var(LOCATION, "Home");
}
else {
$tpl -> set_var(LOCATION, ucwords($location));
}
if (file_exists("pages/".$row['pagename'].".php")) {
$pageinfo = "pages/".$row['pagename'].".php";
}
else {
die("File Does Not Exist");
}
$tpl -> set_var(PAGECONTENT, include($pageinfo));
$tpl -> parse("header_out", array("style", "header"));
$tpl -> parse("footer_out", "footer");
$tpl -> parse("body_out", "body");
$tpl -> p("header_out");
$tpl -> p("body_out");
?>
and this is my include
<?
if (isset($_GET['cat']) && $_GET['cat'] != '') {
echo ucwords($_GET["cat"]).' Jokes';
echo '<br><br><hr><p>';
$query = "SELECT * from jokes WHERE type='".$_GET['cat']."'";
$run = mysql_query($query, $conn) or die(mysql_error());
$up = mysql_query("UPDATE `jokes` SET `viewed` = `viewed` + 1 WHERE `type` = '".$_GET[cat]."'");
while ($row = mysql_fetch_array($run)) {
$joke = $row[JokeText];
$joke = format(0,0,1,1,$joke);
echo "$joke<br><br>";
}
}
else {
echo "welcome to theutherfish.coms jokes section<br><br>";
echo "here you'll find jokes in various subjects to tickle your funny bone,
and make your jaw bone hurt<br><br>";
echo "we always are looking for new jokes and thats why you can submit your own <a href=\"./addjoke.php\" class=\"user\">here</a><br><br>";
}
?>
<hr>
<p>
<?
$cat = "SELECT DISTINCT `type` FROM `jokes`";
$cat_qry = mysql_query($cat, $conn) or die(mysql_error());
echo '<form name="jokecat" action="'.$_SERVER['PHP_SELF'].'" method="GET">';
echo 'Select A Category : <select class="user" name="cat" size="1" onChange="document.jokecat.submit()">';
echo '<option selected>Category....</option>';
while ($cat_arr = mysql_fetch_array($cat_qry)) {
echo '<option>'.ucwords($cat_arr["type"]).'</option>';
}
echo '</select>';
echo ' <input type="submit" value="GO" style="font-family: Verdana; font-size: 8pt; border: 1px solid #C0C0C0; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1">';
echo '</form>';
echo 'Add A Joke : <a href="./add_joke.php" class="user">Click Here</a><br><br>';
?>
also this way where the output is meant to be the number 1 is displayed