Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL

Message Too Old, No Replies

How to include the same table in multiple sites ?

4:41 am on Mar 30, 2011 (gmt 0)


I have 9 websites. I want to include an html table in every footer of those 9 sites. The table code is in a file located on another site (not one of the 9 sites).
All sites are php.

I want this so that I can modify the table from one file instead of having to modify it 9 times.

Is that possible ? And how can I do it ?
11:55 am on Mar 30, 2011 (gmt 0)

I have put the table code in a file called textlinks.inc

Then I used the function:

<?php include("textlinks.inc"); ?>

in every site's footer.

But it doesn't seem to work

1:12 pm on Mar 30, 2011 (gmt 0)

5+ Year Member

Try changing the file extension to .php from .inc
4:36 pm on Mar 30, 2011 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

You can include **any** file, regardless of the extension. You only need the extension to be .php if you want to execute the code in the include (and even then, I think, it will still execute with inc . . . )

<?php include("textlinks.inc"); ?>
<?php include("textlinks.txt"); ?>
<?php include("textlinks.html"); ?>
<?php include("textlinks"); ?>

Anyway when you do this,

<?php include("textlinks.inc"); ?>

... it means the file textlinks.inc must be on the same server, and in the same directory as the php script including it. Is that the case? Doesn't sound like it:

The table code is in a file located on another site (not one of the 9 sites).

You can try

<?php include("https://www.example.com/textlinks.inc"); ?>

But this will fail if the server is not configured with allow_url_fopen or allow_url_include on - which it's often not by default. docs [php.net]

If these "nine sites" are all located, say, on a dedicated server, you **can** configure them and the sites to open the file regardless of location, but you'll have to use the full server path:

<?php include("/var/www/domainname.com/includes/textlinks.inc"); ?>

If neither of these are possible, your only other option would be to then keep nine copies of the same file on all the sites.

Featured Threads

Hot Threads This Week

Hot Threads This Month