nepal12 Posted January 11, 2012 Share Posted January 11, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/254802-help-in-my-script/ Share on other sites More sharing options...
Drongo_III Posted January 11, 2012 Share Posted January 11, 2012 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"; } Quote Link to comment https://forums.phpfreaks.com/topic/254802-help-in-my-script/#findComment-1306504 Share on other sites More sharing options...
nepal12 Posted January 11, 2012 Author Share Posted January 11, 2012 Yes you are right but, I am actually not getting the result. Quote Link to comment https://forums.phpfreaks.com/topic/254802-help-in-my-script/#findComment-1306513 Share on other sites More sharing options...
Drongo_III Posted January 11, 2012 Share Posted January 11, 2012 Well this works fine for me: <?php if(isset($_GET['item']) && !empty($_GET['item'])){ $cat = $_GET['item']; echo $cat; }else{ echo "No menu item selected"; } ?> Can you post what you've done? Quote Link to comment https://forums.phpfreaks.com/topic/254802-help-in-my-script/#findComment-1306520 Share on other sites More sharing options...
nepal12 Posted January 11, 2012 Author Share Posted January 11, 2012 thanks a lot. Actually it worked for me. Quote Link to comment https://forums.phpfreaks.com/topic/254802-help-in-my-script/#findComment-1306592 Share on other sites More sharing options...
Drongo_III Posted January 12, 2012 Share Posted January 12, 2012 Hurrah! thanks a lot. Actually it worked for me. Quote Link to comment https://forums.phpfreaks.com/topic/254802-help-in-my-script/#findComment-1306881 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.