Forum Moderators: coopster
My main page consists of the body (.php) page, and a footer include (.html) and a header include (.html)
Now, i want to set some variables in the body (.php page), so that a certain image will change in the header (.html).
I.E.// i want to change the image displayed at the top of the page, so that it corresponds to the body of the page.
For example, i have two images: car.gif, and bus.gif.
I'm on on the main page of cars, car.php, i want it to pull a "car.gif" image into the header.html file (the header is never changed for any pages).
If i'm on the main page of buses, bus.php, i want it to pull a "bus.gif" image into the header.html file.
The header file never changes, but IMAGES in the header file need to change because of the changing gif files as specified in the body of the php page.
Does this make sense? Is this possible? Any suggestions?
Andrew.
$topic = "cars";
then in the header insert the following, well youll probably need to modify the filename but you get the gist:
<?php
if ($topic == "cars")
{
print "<img src='car.gif'>";
}
else if ($topic == "bus")
{
print "<img src='bus.gif'>";
}
?>
It doesnt matter that the header has the .html extension because it will be imported first, becoming part of the main .php file, thus any PHP code in it will get executed, and because it becomes part of the main file, any variables already set in the main file, before the include, are available.