Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-30-2009, 11:04 PM Help with function
Average Talker

Posts: 16
Trades: 0
Hey guys. I am trying to create a function that will identify a specific module and display it. Here is what I have:

PHP Code:
function mod_display($display_id$display_box$display_title)
{
global 
$db$key$display_id$display_box$display_title$modules$user$auth$display;

$sql "SELECT id, title, display, key FROM mods WHERE id='$display_id'"
$result $db->sql_query($sql); 
$row $db->sql_fetchrow($result);

$key '0';

if (
$key == 1)
{
$display_title='Offline';
$display_box='The module is offline.';
echo (
$display_title);
echo (
$display_box);
}
else
{

if (
$display_title == 0)
{
null;
}
elseif (
$row['title'] == 'Welcome,')
{
echo (
$row['title'] . ' ' $user->data['username']);
}
else
{
echo (
$row['title']);
}

if (
$display_box == 0)
{
null;
}
else 
{
include (
$modules '/' $row['display'] . '.php');
}
}

It works and displays everything, however it doesn't display in the actual module box. It starts at the top, everything is outside of the template at the top. I think that the "include" function is what the problem is. Is there a way to pull a php file without using include? This is what is stopping everything from being displayed right.

Sorry if I am not 100% clear. Please ask for a better description if you don't understand. Thanks!
Ghost Sniper X is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-01-2009, 05:29 AM Re: Help with function
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Perhaps I have not understood the problem correctly, but it seems your calling the function at the top of your page? Call the function inside your template instead, at the place you want the include to happen.
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 05-01-2009, 07:09 AM Re: Help with function
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
Call the function inside your template instead, at the place you want the include to happen.
Exactly, or use ob_start() before the include and ob_get_contents() just after.
It will allow you to get back the HTML that would have been sent to the browser in a variable.

Calling include() is like executing the code.
If there are print or echo statements, or html in the included file, they will be sent to the browser at the moment the function is read (ie, when the page loads) when the engine parse the file to recognize the available functions.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to Help with function
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11865 seconds with 12 queries