Search code examples
phpincludehref

How to include php file based on navigation bar


Hey guys Id like to know what should I put in my href to include files from my class folder.

My site folder structure

folder-class-head.php
            -home.php
            -setting.php
            -footer.php
      -index.php

This is my head.php look like. What should I fill in the href in order to include the the file in my class folder?

<html>
 <head></head>
 <body>
   <a href="">Home</a> <a href="">Setting</a>

my index.php is that the right way to do if statement?

<?
include "class/head.php";
    <--body start-->
   if (do= home.php){
include "class/home.php";
}

if (do= setting.php){

    include "class/setting.php";
}
<--body end -->
<--footer area-->
include "class/footer.php";
?>

Solution

  • you can add like , &page=home to the href, and check if it is home page,

    if($_GET['page']=='home')
    {
    include "class/home.php";
    }