Jump to content

Help in my script


nepal12

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.