Jump to content

PHP's include to work like a frame


blacksaibot

Recommended Posts

Code for index.php:

 

<html>

<head>
  <title>Outer World Investigation Agency</title>
  <link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>

  <center>

  <table cellspacing="0" cellpadding="0" border="0">
   <tr>
    <td>
     <ul id="menu">
      <li><a href="index.html" class="home"></a></li>
      <li><a href="mkvsdc.html" class="mkvsdc"></a></li>
      <li><a href="mk2011.html" class="mk2011"></a></li>
      <li><a href="mkr.html" class="mkr"></a></li>
     </ul>
    </td>
   </tr>
  </table>

  <div id="div-name">
   <?php include("mainpage.html"); ?>
  </div>

</center>

</body>

</html>

 

 

How can I make the links within the included HTML file (mainpage.html) open its contents within itself as if it were a separate frame from my index.php file?

 

Whenever I click a link that's in mainpage.html it opens the link and my PHP file is gone.

My PHP file includes a menu that I don't want to have to re-write over and over again in each HTML page.

Link to comment
Share on other sites

you could make your links point to

<a href="/index.php?site=index"></a>
<a href="/index.php?site=mkvsdc"></a>
... etc.

 

and then change the include to

<?php

if (!$_GET["site"]) {
  //in the case that no site was specified, include index.html
  include "index.html";
} else {
  include $_GET["site"].".html";
}

?>

 

Also, include should be used without brackets

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.