Mass php include help needed

I have a website with 100 pages. I want to include an image in 20 different sections on all 100 pages without having to go in and edit all 100 pages 1 by one because it would take weeks.

Is there any way to use php to include the images into the 20 spots all at once using include or some other function?

Thanks!!

If you have an HTML element with a set id in each of the places you wish to put it, you may be able to do this by modifying your CSS to place the image into elements with that id.

Yes, as Webbwbb mentioned, it depends on your current code. Here are a couple of ways I do this process…

On one site, I have a

tag called “ad_content”. It is on about 4 or 5 pages on one site I maintain.
This
is loaded using CSS which dynamically loads the an image based on a random number. The
“ad_content” is in the form of an image with a name like “advert1.jpg”, etc. The CSS loads the jpg into
the
upon accessing the page.

On another site, I use PHP to load the same type of image. In that code, it displays an image tag using PHP
to create the random number. Something like: echo “<img src=”’/somefolder/advert" . rand(5) . “.jpg’>”;
And, this code is placed into an “included” file and loaded where it is needed.

As a further example, on the current site I am building, I have a header bar that contains two images that
change depending of the user level logged in and an advert pulled depending on the date and if the user has
seen it or not. All of this is placed into a file called “header.php”. And, then I place this on every page of the
site. In this way the display is different for each user. They will not see the same ad each log-in and the main
image notes their user-level. Seems to work very well. And, it give a nice dynamic feel to the header. There
is also an include for the ad-bar on the right side of the site and another for the footer. It all is done with
“includes”.

CSS is nice because you can do fancy border’s, curved corners and can do dynamic image inserts, but, I like
using included files.

Hope these hints give you ideas to use… Good luck!

Sponsor our Newsletter | Privacy Policy | Terms of Service