PHP Menu/Template help

Zaf

Zaf

Soldato
Joined
16 Jan 2003
Posts
7,055
Location
Derbyshire
Hi Guys,

Just starting to get back into PHP and I can for the life of me remember how to create a basic site useing tables instead of html frames.

I want to have two tables, the first will have external links in that will open up in the second table. Getting rid of the need to use HTML Frames.

Can anyone start me off please?

Cheers
Zaf,
 
Had a quick look at XmlHttpRequest() but thats not the way I use to or know how to do it. Before it was just some really simple PHP code.
 
Cheers Rob think your right but how do I use it in the way I want :confused:

Getting links from table 1 to open in table 2

Cheers
Ryan
 
I'm not that well versed with PHP but I guess you could do something using URL GET variables?

Code:
<a href="page.htm?inc=cont1.htm">Home</a>
<a href="page.htm?inc=cont2.htm">Somethingelse</a>
...

<div id="cont">
<?
include ($_GET["inc"]);
?>
</div>

Apologies if I'm doin' it wrong.
 
I've included two examples below, however there is a flaw in what you want to do tables nor divs were designed to have another "whole" website embedded in them, so you will get CSS related problems and invalid html (which is why frames and Microsoft’s iframe tag exist). Also it could be a bit of a security risk.. (which is why nobody does it)

Note: The two sites in the examples will not display properly because of the CSS problem (as it is inserting one html doc into another, which screws it up).

Example using two tables, with php:

PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table width="25%" border="1">
  <tr>
    <td>Links</td>
  </tr>
  <tr>
    <td><a href="?link=ocuk">Overclockers</a></td>
  </tr>
  <tr>
   <td><a href="?link=google">Google</a></td>
  </tr>
</table>
<table width="100%" border="1">
  <tr>
    <td><?php
	switch ($_GET['link']) {
	  case 'ocuk':
	  include('http://www.overclockers.co.uk');
      break;
	  case 'google':
	  include('http://www.google.co.uk');
      break;
	 default:
      print("&nbsp;");
  	}
	?></td>
  </tr>
</table>
</body>
</html>

Example using just ajax, one table and one div:
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
  <script type="text/javascript">
    var http = false;

    if(navigator.appName == "Microsoft Internet Explorer") {
      http = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
       http = new XMLHttpRequest();
    }

    function getlink(link) {
      http.open("GET", link, true );
      http.onreadystatechange=function() {
        if(http.readyState == 4) {
          document.getElementById('extlink').innerHTML = http.responseText;
        }
      }
      http.send(null);
    }
  </script>
</head>
<body>
<table width="25%" border="1">
  <tr>
    <td>Links</td>
  </tr>
  <tr>
    <td><a href="javascript:getlink('http://www.overclockers.co.uk')">Overclockers</a></td>
  </tr>
   <tr>
    <td><a href="javascript:getlink('http://www.google.co.uk')">Google</a></td>
  </tr>
</table>
<div id="extlink"> 	
</div>
</body>
</html>
 
Cheers Dan I think i've been looking at this the wrong way :o

I need a header.php and a body.php both displayed on the same index.php useing include I guess. then I need the header links displayed in the body

Does that sound right? If so what code do I use with the links in header.php to be displayed in body.php

Cheers
Zaf,
 
having another look I dont think that will work either, any ideas on a better way of displaying an external website link from top of the page onto main page? So the external links are always displayed at the top as if you were useing a frameset?

Cheers Again
Zaf,

sorry for sounding stupid guys its been a long time since I touched any type of webdesign code :-p
 
Cheers for all the input guys, i've gone back to just useing frames but doing it this way I cant get images right to the top of the page e.g

framevt3.jpg


here I have two frames, the top frame has a background gradient image and a logo image but I cant get the logo to align up.
 
Already got border=0 heres the code

Index
Code:
<html>

<frameset rows="40,*" border="0">

  <frame noresize="noresize" src="menu.php">

  <frame src="main.php" name="showframe">


</frameset>

</html>

Menu
Code:
<html>
<head>
<title>Windows Monitor</title>

</head>
<body background="images/Untitled-1_03.png" scroll="no">

<img src="images/Untitled-1_02.png" width="195" height="40" alt="">


</body>
</html>

Cheers
Zaf
 
Last edited:
If I set the border like this I still get the same result.

Code:
<html>
<head>
<title>Windows Monitor</title>

</head>
<body background="images/Untitled-1_03.png" scroll="no" border="0">

<img src="images/Untitled-1_02.png" width="195" height="40" alt="">


</body>
</html>

Any ideas?
 
I've tryed inserting a css making the margin zero pixels but I still get the same effect I cant get any images right to the top of the page
 
Hey Zaf,

I really would suggest you do things differently - e.g. don't use frames, use phps include() to include the header/navbar/footer on each page, use CSS markup... I just get the feeling that you're doing things "the old-fashioned way" and really I think you should learn how to do things the "modern" way! Otherwise you're practising ways to do things that people try not to do anymore.

Put all the CSS styling in an external CSS file, like this for example:

Code:
/* filename: css/main.css */
body {
    margin: 0px;
    padding: 0px;
    background-image: url(images/Untitled-1_03.png);
    background-repeat: repeat-x;
    background-position: top;
}
img {
    border: 0px solid #FFFFFF;
}
Which is really nice, as it keeps your styling code separate from your HTML code.

I'm gonna go into more detail about this header/footer thing. I think you should do something like this:

PHP:
<?php
/* filename: index.php (or whatever other page) */
include('header.inc.php');
?>

<img src="images/Untitled-1_02.png" width="195" height="40" alt="My Image">

<div>And whatever else you want on your page</div>

<?php
include('footer.inc.php');
?>

Then your header/footer files:
PHP:
<?php /* filename: header.inc.php */ ?>
<html>
<head>
<title>Windows Monitor</title>
<link rel="stylesheet" type="text/css" href="css/main.css" />
</head>
<body>
<?php /* SOME PHP CODE TO GENERATE YOUR NAVIGATION MENU ETC ETC */ ?>


PHP:
<?php /* filename: footer.inc.php */ ?>
</body>
</html>

Then that header/footer will appear on each page you include them on. Having a similar effect to frames, but without the frames...

Apologies in advance if there's some reason you're not doing this already and I just haven't realised what it is ;)
 
He wants to have external pages/websites embedded into his site and they will not display properly by using include with a div..
 
Back
Top Bottom