homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Gold Sponsor 2015!
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

How to include the same table in multiple sites ?

Msg#: 4289364 posted 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 ?



Msg#: 4289364 posted 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



5+ Year Member

Msg#: 4289364 posted 1:12 pm on Mar 30, 2011 (gmt 0)

Try changing the file extension to .php from .inc


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

Msg#: 4289364 posted 4:36 pm on Mar 30, 2011 (gmt 0)

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved