Jump to content

Include()


glenelkins

Recommended Posts

Hi

Lets say for instance i have a function that generates a block (displayed with a table Title, and Content). Now say some of these blocks need more than static content. I include a file to run within the code and build up the $content variable. I then use another display function to display the content. How would i include that php code and once the values have been decided for $content the included code is then removed. include_once() and include are not doing what i need as they are in a loop, i need to include, then un-include
Link to comment
https://forums.phpfreaks.com/topic/26926-include/
Share on other sites

actually no that wont work. As when the file is included it is still there, due to the fact its being included as a different file each time in a loop.

[code]
function GenerateBlocks ($position,$template) {
$result = $this->DbQuery ("SELECT * FROM blocks WHERE position='$position'") or die (mysql_error());
while ($blocks = mysql_fetch_array($result)) {
if ($blocks['active'] == '1') {
echo $blocks['title'] . "<br>";
if ($blocks['admin'] == '1' && $_SESSION['level'] == '1' or $blocks['admin'] == '0') {
if ($blocks['members'] == '0' xor $blocks['members'] == '1' && $_SESSION['logged'] == 'yes') {
if ($blocks['file'] == '1') {
require_once (BLOCKS_FOLDER . $blocks['filename']);
$content = array($blocks['title'],$content);
} else {
$content = array($blocks['title'],$blocks['content']);
}

$tags = array("{title}","{content}");
$block .= $this->GenerateContent($tags,$content,$template,"block.html");
}
}
}
}

return $block;
}
[/code]

so basically require_once, read code... take out
Link to comment
https://forums.phpfreaks.com/topic/26926-include/#findComment-123141
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.