4 Replies - 1833 Views - Last Post: 21 July 2001 - 08:38 PM Rate Topic: -----

#1 kkurkowski  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 21-July 01

PHP Navagation Help

Posted 21 July 2001 - 07:39 PM

Can someone please help me with this?
On some sites, they have a PHP file, and the little navagation thing is always on every page you look at that is linking to that php file. So If I wanna change the little navagation thing I can change the PHP file and it will change on every page. Does anyone know what I am talking about?
I probably just confused everyone.
Is This A Good Question/Topic? 0
  • +

Replies To: PHP Navagation Help

#2 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1876
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

Re: PHP Navagation Help

Posted 21 July 2001 - 07:55 PM

I know exactly what your talking bout cause that's how I'm gonna do this site

let me track down a tutorial for you
and I'll let you know in a few

Was This Post Helpful? 0
  • +
  • -

#3 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1876
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

Re: PHP Navagation Help

Posted 21 July 2001 - 08:09 PM

Here is another example, using an include:
<HTML>
<HEAD>
 <TITLE>This is my page!</TITLE>
</HEAD>
< BODY>
HTML code... <? require("nav.inc"); ?> ...HTML code... <? PHP code ?> ...HTML code... etc...
</BODY>
</HTML>
The require expression tells the server to stick in the contents of the file named "nav.inc", instead of the PHP tag. Let's say this file contains the main navigation table for your site and looks like this:

this is the beginning of the file

<TABLE CLASS="nav">
 <TR>
   <TD><A HREF="/" TITLE="Home page">Home</A></TD>
   <TD><A HREF="/computers/" TITLE="Everything about computers">Computers</A></TD>
   ...
      </TR>
</TABLE>

the file ends here
This is what the server sends to the browser:

<HTML>
<HEAD>
 <TITLE>This is my page!</TITLE>
</HEAD>
<BODY>
HTML code...

<TABLE CLASS="nav">
 <TR>
   <TD><A HREF="/" TITLE="Home page">Home</A></TD>
   <TD><A HREF="/computers/" TITLE="Everything about computers">Computers</A></TD>
   ...
      </TR>
</TABLE>

...more HTML code... <? PHP code ?> ...HTML code... etc... </BODY>
Again, the browser has no idea that PHP exists.

More about includes
As it should be clear from the example above, an include is a simple ASCII file, and there is no special "dressing" to put around it. Just cut out a chunk of HTML from a page and stick it in a separate file: you have an include.

Include files can have any extension. You can name an include "blahblah.bla" if you wish.
It is common to name them "something.inc", but using other extensions can sometimes make sense. For example, a file with a ".txt" extension will be viewable directly in most browsers, whereas trying to view includes with other extensions may simply result in the browser prompting you to "save as...". I have often used ".des" for some of my files to indicate that they were "design" files. Naming includes is a perfectly personal choice.

The require function replaces itself with the contents of the file it calls, whereas include is more like a branch that points to it. This can make a difference if you are using a loop to call different includes: if you use require, the statement will be replaced by the first file during the first loop, and you will end up with (e.g.) three times the same file instead of three different files. If you are not quite sure which to choose, follow this rule of thumb: In control statements and functions, use include. Otherwise, use require (which is supposed to be a little faster).

An include can call another include. The include is read just as a normal PHP file, which means that you can put in an include anything that you would put in a "normal" PHP file.

Calling an include with relative or server-relative urls sometimes creates trouble. I haven't quite sorted out this question yet, and will update this tutorial as soon as I have. Until then, if problems persist, use absolute urls, of the form "http://www.users.f2s.com/test/support/whatever/myfile.inc". And let me know if you have solved the problem!

You may also try this link:
http://www.phpbuilde...ll20001122.php3


Was This Post Helpful? 0
  • +
  • -

#4 kkurkowski  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 21-July 01

Re: PHP Navagation Help

Posted 21 July 2001 - 08:18 PM

Example of the type thing I want to do here. All of this kids stuff is always on the left side of the page even though you click it link. But you only have to edit the one PHP file to change it on every page.
http://www.tkohnen.com
Was This Post Helpful? 0
  • +
  • -

#5 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1876
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

Re: PHP Navagation Help

Posted 21 July 2001 - 08:38 PM

yeh, what you do is in your HTML file  just make your main page then cut out the nav
and replace it with the include tag from above then in the .inc file put the HTML from the nav
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1