Jump to content

[SOLVED] finding a "like" current page


samoht

Recommended Posts

ok, back for more  ;)

I now have my queries and the main level ul class changes nicely to "current" showing the user where they are.

However, I want to keep the main tab current if the user navigates inside the pages available under that tab. (e.g. sauser.php is a sub link under the "Secure Access" tab. once there a user can navigate to sauseredit.php or sauserview.php  - fortunately the new pages will always start with the same base page in there names

<?php
$page = basename($_SERVER['SCRIPT_NAME']);
			while ($row = mysql_fetch_assoc($navBarsSA)) {
				$linkurls[] = $row['LinkURL']; // add new array element to $linkurls, an array
				if ($row['LinkURL'] == $page) {
				 $currentType = $row['Type'];
				 }?>

- so if I could check for what ever comes before the .php and then test to see if that starts the name of the new page navigated too then I could keep the proper tab current)

 

or if the if($row['LinkURL']==$page) could be Like%...% istead of == ?

 

hopefullly that all makes sense.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/61471-solved-finding-a-like-current-page/
Share on other sites

changing to that did not work?

 

<?php 				while ($row = mysql_fetch_assoc($navBarsSA)) {
				$linkurls[] = $row['LinkURL']; // add new array element to $linkurls, an array
				if (strtolower($row['LinkURL']) == substr(strtolower($page), 0, -4)) {

				 $currentType = $row['Type'];
				 }

			}?>

 

is the syntax correct the way I have it?

I found my problem ans switched the order

 

<?php	$rpage = basename($_SERVER['SCRIPT_NAME']);
	$page = substr(($rpage),0,6);
//stuff...
if (substr(($row['LinkURL']),0,6) == $page)

 

the shorest link I have was 6 characters long so this works just fine as long as my links are unique with in the first 6 characters.

 

Thanks for the help!!

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.