Note that there are some explanatory texts on larger screens.

plurals
  1. POLink to internal pages from include file - correct path from each page
    text
    copied!<p>I have an include file which contains the header section for each of my pages. What I am finding difficult to grasp is the fact that my index.php file is in the root of my directory but my other pages are in the pages folder. How can I correctly link it so that when I am on the shows page for example, I can link back to the home page. You might just say do something like ../home.php but what happens when I am actually on the home page, how do I then link to the other pages because I cannot do show.php because it is not in the same directory as the index.php file. I have only one header file for all these hyperlinks remember which is why I am finding it difficult...</p> <p>My directory is as follows:</p> <p><strong>css</strong></p> <p><strong>fonts</strong></p> <p><strong>images</strong></p> <p><strong>includes</strong></p> <ul> <li>header.php</li> </ul> <p><strong>js</strong></p> <p><strong>pages</strong></p> <ul> <li>about.php</li> <li>classes.php</li> <li>contact.php</li> <li>noticeboard.php</li> <li>shows.php</li> </ul> <p><strong>index.php</strong></p> <p>Below are my links on what I have achieved so far:</p> <pre><code>&lt;li&gt;&lt;a &lt;?php if (strpos($_SERVER['PHP_SELF'], 'index.php')) echo 'class="current"';?&gt; href="../index.php"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a &lt;?php if (strpos($_SERVER['PHP_SELF'], 'shows.php')) echo 'class="current"';?&gt; href="shows.php"&gt;Shows&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a &lt;?php if (strpos($_SERVER['PHP_SELF'], 'classes.php')) echo 'class="current"';?&gt; href="classes.php"&gt;Classes&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a &lt;?php if (strpos($_SERVER['PHP_SELF'], 'noticeboard.php')) echo 'class="current"';?&gt; href="noticeboard.php"&gt;Notice Board&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a &lt;?php if (strpos($_SERVER['PHP_SELF'], 'about.php')) echo 'class="current"';?&gt; href="about.php"&gt;Our Story&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a &lt;?php if (strpos($_SERVER['PHP_SELF'], 'contact.php')) echo 'class="current"';?&gt; href="contact.php"&gt;Contact&lt;/a&gt;&lt;/li&gt; </code></pre> <p>Thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload