tags:

views:

60

answers:

3

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 show\load 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

+3  A: 

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.

eg:

include("subfolder/links.html");
krike
not working already tried that
Junaid Saeed
that's not possible, I have been using include for years. it is used to include other files into php files. Are you sure you created a php file named index.php like you mentioned? and it's in that file you want to show the content of those 2 external files?
krike
yes... and i know how the paths work.... i have been googling it... it something to with innerhtml
Junaid Saeed
Have you tried to rename the links.html to links.php to that the php gets evaluated? If you see <?php include("contents.php"); ?> in your html page, this is the case.
Leon
the .php file has been loaded but not the .html file
Junaid Saeed
@krike: my vote is locked in.. edit your answer... i need to vote up
Junaid Saeed
@Moon: i edited my anwser
krike
+1  A: 

Use the require function to add the content of the other files to your template.

<html>
<body>
    <div id="links" class="myCustom1">
       <?php require('links.html'); ?>
    </div>

    <div id="contents" class="myCustom2">
        <?php require('content.php'); ?>
    </div>
</body>
<html>
mmanco
didn't work....
Junaid Saeed
Please carefully recheck your code. It should work for sure.Or, add more details on the problem you facing.
mmanco
A: 

use the code people posted above, but make links.html a php file..

OR if you really dont want to do this you can tell the PHP engine to parse HTML pages.

Adam