Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Need help with my script

Links for php scripts

Moderators: macek, egami, gesf

Need help with my script

Postby nepal12 » Wed Jan 11, 2012 7:21 am

Hi guys,

I have an issue.

First see my 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
nepal12
New php-forum User
New php-forum User
 
Posts: 7
Joined: Tue Jan 03, 2012 11:35 am

Re: Need help with my script

Postby lonelygirl86 » Wed Jan 11, 2012 5:16 pm

Make your menu like this

Code: Select all
<ul>
<li><a href="index.php?item=Menu1">Menu 1 </a></li>
<li> <a href="index.php?item=Menu1">Menu 2 </a>li>
<li><a href="index.php?item=Menu1"> Menu 3</a> </li>
<li><a href="index.php?item=Menu1"> Menu 4</a> </li>
</ul>


which mean, you are passing item to index.php.

You gotta read on this, PHP GET
http://www.w3schools.com/php/php_get.asp
lonelygirl86
New php-forum User
New php-forum User
 
Posts: 14
Joined: Mon Jan 09, 2012 12:05 am


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.