473,241 Members | 1,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

weird stuff with include statement

Hey guys, please bear with me cause I am a major newbie at php. I am
building a website and have it so that the content in the middle of the
page changes but the banner on top and the panels on the sides do not.
The way I am doing this is by having a top.php file and a bottom.php
file and in my file index.php it would look like this:
<?php
include("top.php");
?>
Here is my index stuff...
<?php
include("bottom.php");
?>

and that works great. However, I thought it would be cool to have it so
that one of the panels changed for each website so that it was specific
to the page you were on but the others stayed the same. So I thought I
could do include("top.php?panel=homepage"); and edit the top.php page
accordingly. However, this does not work. Thanks so much for your help.

Matt

Jul 17 '05 #1
5 1489
On 1 Jul 2005 14:36:02 -0700, md******@gmail.com wrote:
Hey guys, please bear with me cause I am a major newbie at php. I am
building a website and have it so that the content in the middle of the
page changes but the banner on top and the panels on the sides do not.
The way I am doing this is by having a top.php file and a bottom.php
file and in my file index.php it would look like this:
<?php
include("top.php");
?>
Here is my index stuff...
<?php
include("bottom.php");
?>

and that works great. However, I thought it would be cool to have it so
that one of the panels changed for each website so that it was specific
to the page you were on but the others stayed the same. So I thought I
could do include("top.php?panel=homepage"); and edit the top.php page
accordingly. However, this does not work. Thanks so much for your help.


?panel=homepage is for HTTP requests.

This include() is not doing an HTTP request, it is reading from the
filesystem.

There's no such file named "top.php?panel=homepage". So it won't work.

Since this is PHP reading PHP, you simply set the appropriate variable in your
outer file, and the file in the inner scope have it available as described in
the manual.

http://uk2.php.net/include/

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
* Andy Hassall wrote:
On 1 Jul 2005 14:36:02 -0700, md******@gmail.com wrote:
Hey guys, please bear with me cause I am a major newbie at php. I am
building a website and have it so that the content in the middle of the
page changes but the banner on top and the panels on the sides do not.
The way I am doing this is by having a top.php file and a bottom.php
file and in my file index.php it would look like this:
<?php
include("top.php");
?>
Here is my index stuff...
<?php
include("bottom.php");
?>

and that works great. However, I thought it would be cool to have it so
that one of the panels changed for each website so that it was specific
to the page you were on but the others stayed the same. So I thought I
could do include("top.php?panel=homepage"); and edit the top.php page
accordingly. However, this does not work. Thanks so much for your help.


?panel=homepage is for HTTP requests.

This include() is not doing an HTTP request, it is reading from the
filesystem.


Correct!

But what he really want to know is how to make it work in real life, not
only the technical reason it doesn't.

Matt, what you will have to do is to have some function to call for in the
top.php and bottom.php if you want to have some kind of dynamic content.

What you could do is something like this:

<?php
//this is top.php
function write_1()
{
echo 'This is 1';
}
?>

<?php
//this is bottom.php
function write_2()
{
echo 'This is 2';
}
?>
<?php
//This is mainfile, e.g. index.php
include("top.php");
write_1();
?>
Here is my index stuff...
<?php
include("bottom.php");
write_2();
?>
--

Thomas
Jul 17 '05 #3
Thomas Kaarud wrote:
* Andy Hassall wrote:
On 1 Jul 2005 14:36:02 -0700, md******@gmail.com wrote:
Hey guys, please bear with me cause I am a major newbie at php. I am
building a website and have it so that the content in the middle of the
page changes but the banner on top and the panels on the sides do not.
The way I am doing this is by having a top.php file and a bottom.php
file and in my file index.php it would look like this:
<?php
include("top.php");
?>
Here is my index stuff...
<?php
include("bottom.php");
?>

and that works great. However, I thought it would be cool to have it so
that one of the panels changed for each website so that it was specific
to the page you were on but the others stayed the same. So I thought I
could do include("top.php?panel=homepage"); and edit the top.php page
accordingly. However, this does not work. Thanks so much for your help.

?panel=homepage is for HTTP requests.

This include() is not doing an HTTP request, it is reading from the
filesystem.

Correct!

But what he really want to know is how to make it work in real life,
not only the technical reason it doesn't.

Matt, what you will have to do is to have some function to call for in
the top.php and bottom.php if you want to have some kind of dynamic
content.

What you could do is something like this:

<?php
//this is top.php
function write_1()
{
echo 'This is 1';
}
?>

<?php
//this is bottom.php
function write_2()
{
echo 'This is 2';
}
?>
<?php
//This is mainfile, e.g. index.php
include("top.php");
write_1();
?>
Here is my index stuff...
<?php
include("bottom.php");
write_2();
?>

Why go to all that trouble?

Just put

<?php
echo "This is 1";
?>

in top.php and include it where you want it (instead of calling a function).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #4
* Jerry Stuckle wrote:
Thomas Kaarud wrote:
<?php
//this is top.php
function write_1()
{
echo 'This is 1';
}
?>
<?php
//this is bottom.php
function write_2()
{
echo 'This is 2';
}
?>
<?php
//This is mainfile, e.g. index.php
include("top.php");
write_1();
?>
Here is my index stuff...
<?php
include("bottom.php");
write_2();
?>

Why go to all that trouble?

Just put

<?php
echo "This is 1";
?>

in top.php and include it where you want it (instead of calling a
function).


Ofcourse, but it seems like this being a person who want to know how to
use included files, and obviously you don't have a singe included file for
any kind of include you would like....

--
Thomas
Jul 17 '05 #5
Thanks for your help guys. Worked perfectly.

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: redneck_kiwi | last post by:
Hi all: I have a really weird problem. I am developing a customer catalog system for my company and as such have delved into sessions for authentication and access levels. So far, I have managed...
2
by: alice | last post by:
Hi, When I compiles the following program with g++, it gives the following output: # g++ -o list list.C list.C: In function `int main()': list.C:116: jump to case label list.C:110: crosses...
8
by: G Patel | last post by:
Can people please comment on the layout/style of my problem? The major issue I had was the layout. I ended up having to put a relatively large switch statement, inside an if statement, which is...
0
by: Zwyatt | last post by:
having a really weird little bug w/ time_t...check it out: I have the following code (simplified here): #include <time.h> class A { public: char *aString; int aNum;
2
by: WisTex | last post by:
I've come across a very weird problem. Virtual includes work on all my ASP pages on the entire website, including those in subdirectories, yet they won't work on a particular page I created, even...
13
by: guitarromantic | last post by:
Hey everyone. I'm editing some stuff I did last summer, trying to bugfix and improve stuff. One improvement (or an oversight of the original design) is adding dynamic <title> tags to my pages....
5
by: Pupeno | last post by:
Hello, I am experiencing a weird behavior that is driving me crazy. I have module called Sensors containing, among other things: class Manager: def getStatus(self): print "getStatus(self=%s)"...
12
by: MQ.john | last post by:
//Working Example: #include <stdio.h> #include <time.h> int main () { time_t rawtime; /* define rawtime as time_t */ time ( &rawtime );
7
by: dtschoepe | last post by:
Hi, I am working on a project for school and I am trying to get my head around something weird. I have a function setup which is used to get an input from stdin and a piece of memory is created...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.