Page 1 of 1

PHP Header files with links

Posted: Mon Aug 22, 2005 1:14 am
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.

Posted: Mon Aug 22, 2005 1:24 am
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 =]

Posted: Mon Aug 22, 2005 4:46 am
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;
}

Posted: Tue Aug 23, 2005 12:05 am
by northstars23
perfect! thanks alot