Jump to content

Recommended Posts

Hi guys,

 

I have an issue.

 

First see the code.

 

1) index.php

 

 

<html>

<?php include 'header.php';?>

 

<div class = "nav">

    <ul>

        <li> Menu 1 </li>

        <li> Menu 2 </li>

        <li> Menu 3 </li>

        <li> Menu 4 </li>

    </ul>

</div>

 

  <div id = "left-panel">

    <ul class = "left-menu">

 

      <li>Sub Menu 1 </li>

      <li>Sub Menu 2 </li>

      <li>Sub Menu 3 </li>

      <li>Sub Menu 4 </li>

 

    </ul>

  </div>

 

  <div class = "content">

  <?php loadContent($config); ?>

  </div>

 

<?php include 'footer.php' ?>

 

</html>

 

My Function is:

 

function loadContent($config)

{

if(empty($_GET['action']))

{

$_GET['action'] = "start";

}

$root = "include/".$_GET['action'].".php";

 

if(file_exists($root))

{

include($root);

}

 

}

 

No if I press the Menu 1 in the nav class I will redirect to index.php?action=category&item=Menu1

 

My question is can I detect the $_GET['item']; in the index page and print it. If so how can I ?

 

I want like :

 

if (empty($_GET['item'])){

    echo "No menu item selected";

    }else{

  $cat = $_GET['item'];

  echo $cat;

  }

 

at the top of the page

Link to comment
https://forums.phpfreaks.com/topic/254802-help-in-my-script/
Share on other sites

You've pretty much answered your own question really with one minor change.

 

You probably want to check if the 'item' variable is actually set first and then make sure it's not empty. e.g.

 



if(isset($_GET['item']) && !empty($_GET['item'])){

            $cat = $_GET['item'];   
            echo $cat;

    }else{
    echo "No menu item selected";

   }



Link to comment
https://forums.phpfreaks.com/topic/254802-help-in-my-script/#findComment-1306504
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.