PHP Header files with links

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
northstars23
Forum Newbie
Posts: 2
Joined: Mon Aug 22, 2005 1:08 am

PHP Header files with links

Post by northstars23 »

I am fairly new at PHP and I started working on a site that uses includes for a header and a footer. The question that I have is that I want to link to different javascript source files depending on the page, but the links are in the header file. So, how do I define these links in the content section? I am sure this is pretty easy to do, but I haven't been able to find anything after googling for some time now.
sticksys
Forum Commoner
Posts: 33
Joined: Thu Aug 18, 2005 3:23 am
Location: Isreal
Contact:

Post by sticksys »

If you will use "Switch", than every one and one of the pages will be the "index.php" with $_GET method,

example:

index.php?a=u&w=login


any page will be in the same link, so you will not have these problems.


Php.net:

http://il2.php.net/switch




good luck =]
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

put these in the first lines of the page.

Code: Select all

switch ($_SERVER["PHP_SELF"]){
case "file1.php":
echo "<script type=\"text/javascript\"  src=\"file1.js\"></script>";
break;
case "file2.php":
echo "<script type=\"text/javascript\"  src=\"file1.js\"></script>";
break;
}
northstars23
Forum Newbie
Posts: 2
Joined: Mon Aug 22, 2005 1:08 am

Post by northstars23 »

perfect! thanks alot
Post Reply