Each week I feature one of my answers on stackoverflow hoping it might help other people.
This weeks question by Junaid Saeed: load HTMLPHP pages into another Page’s div
lets say i have two pages links.html & contents.php… first page contains only html code while the second page contains some HTML + PHP code….
now i ant to create a page index.php with two DIVs in which i want to showload the above two pages…
<html> <body> <div id="links" class="myCustom1"> <!--here will be the links.html page--> </div> <div id="contents" class="myCustom2"> <!--here will be the contents.php page--> </div> </body> <html>
HOW TO DO IT
you can use the include functions (require(), require_once() functions would work as well), like this:
(change links.html to links.php)
<html> <body> <div id="links" class="myCustom1"> <?php include("links.php"); ?> </div> <div id="contents" class="myCustom2"> <?php include("contents.php"); ?> </div> </body> <html>
I set it to links.html which is your filename but if it’s in a subdirectory you need to specify it as well.
include("subfolder/links.php"); //You cant include html files and therefore it should be a php file