473,770 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ph p");
?>
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.ph p?panel=homepag e"); and edit the top.php page
accordingly. However, this does not work. Thanks so much for your help.

Matt

Jul 17 '05 #1
5 1514
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.p hp");
?>
Here is my index stuff...
<?php
include("botto m.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.ph p?panel=homepag e"); 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.andyhsoftwa re.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.ph p");
?>
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.ph p?panel=homepag e"); 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.ph p");
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.ph p");
?>
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.ph p?panel=homepag e"); 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.ph p");
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*******@attgl obal.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.ph p");
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
2080
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 to get a working system just about finished. I am building an interface for our customer service folks to use to manage registered customers and am seeing some weird behavior.
2
6774
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 initialization of `std::string data' list.C:120: jump to case label list.C:110: crosses initialization of `std::string data'
8
1923
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 inside a while loop. If someone can tell me how I can rearrange these elements a little to make it cleaner, I would appreciate that. I've tested it on the command line, and it works *well*, but the source code layout is bugging me. I'd also...
0
1450
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
4641
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 though the virtual include statement is copy & pasted exactly as it appears on the working pages. What would cause virtual includes to work in one page on a website, but not on another? Error Message: Microsoft VBScript runtime error...
13
1652
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. Here's how I originally structured my php pages: include header.php (contents are basically my HTML/CSS up to the <!--begin content--> point) <php code>
5
1715
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)" % self return {"a": "b", "c": "d"} and then I have another module called SensorSingleton that emulates the
12
1933
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
2013
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 on the heap using malloc. This input is then run through a regex and another test. The result is passed back as a char pointer to the program for further processing The first time I call this function, it performs normally. However,
0
10254
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7451
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.