Welcome to WebmasterWorld Guest from 22.214.171.124 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
How to include the same table in multiple sites ? papa_mia msg:4289366 4:41 am on Mar 30, 2011 (gmt 0) Hello 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 ?
papa_mia msg:4289464 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 ? bw100 msg:4289474 1:12 pm on Mar 30, 2011 (gmt 0)
Try changing the file extension to .php from .inc rocknbil msg:4289584 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.