UFOman
UFOman

Reputation:

PHP base navigation help

currently i have :

$page = basename($_SERVER['REQUEST_URI']);

<li<?php if($page == 'index.php?page=product') print ' id="current"'; ?>><a href="index.php?page=product">Products</a></li>

but however when url is something like index.php?page=product&item=100

the class 'id=current' doesn't apply.

any workaround?

thank you for help.

Upvotes: 0

Views: 110

Answers (3)

txyoji
txyoji

Reputation: 6878

If you'd like to see what is being sent to the $_GET and $_POST vars, you can dump them to the page with this one liner: <?php echo '<pre>' . print_r($_GET,true) . '</pre>'; ?>

Upvotes: 0

erenon
erenon

Reputation: 19158

$page = $_SERVER['PHP_SELF'].'?'.$_GET['page'];

Upvotes: 0

chelmertz
chelmertz

Reputation: 20601

if($_GET['page'] == 'product') instead of if($page == 'index.php?page=product')

Upvotes: 5

Related Questions