0

I am trying to load a projects.php file into a higher-level index.php file and want to maintain all the .js .css and any further nested (in .js files) .php files, that are declared in the projects.php file.

My index.php file goes like:

<!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=utf-8" />
<title>BLST</title>
</head>

<body>
    <?php $projectsPage = "/tables/php/projects.php"?>
    <li><a href="index.php?page=<?php echo $projectsPage;?>">Projects</a></li>
    <?php if(is_null($_GET["page"])) { 
                $page = ""; 
        }else{ 
            $page = $_GET["page"]; 
        } 
       include($page); 
    ?>
</body>
</html>

My projects.php file is

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />

        <title>Projects</title>

        <style type="text/css">
            @import "css/test.css";
            @import "http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.23/themes/smoothness/jquery-ui.css";
        </style>

        <script type="text/javascript" language="javascript" charset="utf-8" src="js/jquery.min.js"></script>
    </head>

The issue is that none of the files in projects.php are found. This is because the browser is looking to my main directory now (where index.php is).

11
  • The js should be called. Ill need to see a little more, like the generated code or a live example or more code ;P Commented Mar 24, 2014 at 19:28
  • It should work. Does those includes appear in page's source? Commented Mar 24, 2014 at 19:33
  • Why wouldn't it work? Worked perfectly well for me. You may want to add a closing semi-colon <?php include "stuff.php"; ?> but I doubt it; both worked. Commented Mar 24, 2014 at 19:33
  • If I load /php/stuff.php, everything works. I have a few js files (that are using AJAX and calling further nested php files). But if I load /php/stuff.php into index.php (which is about 5 levels up) basically every php, js and css link is broken in stuff.php. Commented Mar 24, 2014 at 19:34
  • Try omitting all closing ?> tags then; they're not really required 95% of the time. Commented Mar 24, 2014 at 19:36

1 Answer 1

1

The test.css is in "tables/php/css/test.css" and what about the location of projects.php and index.php.

I think the answer to these will solve the problem.

Sign up to request clarification or add additional context in comments.

4 Comments

I know where the files are, I need to know how to point my index.php to them.
Yes that is what you have to tell me as to where these files are located so that I could help you out.
Okay let's say: "htdocs/index.php", "htdocs/tables/php/projects.php", "htrocs/tables/php/css/test.css", "htdocs/tables/php/js/jquery.min.js" etc
Alright in that case try giving the path for test.css as '/tables/php/css/test.css' in projects.php and see if it works. Similarly do the same for jquery.min.js. Try this and let me know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.