Raffels,
Thanks for the help and the suggestions. The variable names are not mine - the site I am cleaning up from a previous person - and I agree with you.
Concerning my ul li structure - it differs from the traditional because I have a drop line navigation and I want to be able to control the position of the sub links
so instead of:
Code:
<ul>
<li>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</li>
<li>
<ul> /*etc*/
I have:
Code:
<ul>
<li>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</li>
</ul>
<ul>
<li>
<ul> /*etc*/
so that I can have a unique class for each main nav or tab and then position the sublinks accordingly. If there is a better way of doing this I am certainly open to suggestions.
I now have a working loop array loop:
PHP Code:
<?php
$page = basename($_SERVER['SCRIPT_NAME']);
$NavBarsExist = false;
mysql_select_db($database_connection1, $connection1);
$query_rsSANavBars = "SELECT * FROM sanavbars WHERE Type = 'SA' AND FlagStatus = 'A' ORDER BY Name";
$rsSANavBars = mysql_query($query_rsSANavBars, $connection1) or die(mysql_error());
//$row_rsSANavBars = mysql_fetch_assoc($rsSANavBars);
$totalRows_rsSANavBars = mysql_num_rows($rsSANavBars);
if ($totalRows_rsSANavBars > 0) {
while ($row = mysql_fetch_assoc($rsSANavBars)) {
$linkurls[] = $row['LinkURL']; // add new array element to $linkurls, an array
if ($row['LinkURL'] == $page) {
$currentType = $row['Type'];
}
}
// Now, if $currentType is set, then there was a match with $page
if($currentType == 'SA'){$c = 'current';}else{$c = 'adminnav';}
//$c = $cl ? $c = 'current' : 'adminnav';
echo '<ul class="' .$c . ' one"><li><a href="'.$page.'?current=one&sub=none"><b>Secure Access</b><!--[if IE 7]><!--></a><!--<![endif]-->'."\n";
echo '<!--[if lte IE 6]><table><tr><td><![endif]-->'."\n";
echo '<ul class="sub" id="navlight">'."\n";
mysql_data_seek($rsSANavBars,0);
while ($row_rsSANavBars = mysql_fetch_assoc($rsSANavBars)) {
$SANavBarId = $row_rsSANavBars['NavBarId'];
mysql_select_db($database_connection1, $connection1);
$query_rsSAUserNavBars = "SELECT * FROM sausernavbars WHERE SAUserId = '$SAUserId' AND SANavBarId = '$SANavBarId' AND FlagStatus = 'A'";
$rsSAUserNavBars = mysql_query($query_rsSAUserNavBars, $connection1) or die(mysql_error());
$row_rsSAUserNavBars = mysql_fetch_assoc($rsSAUserNavBars);
$totalRows_rsSAUserNavBars = mysql_num_rows($rsSAUserNavBars);
// show navbar if user has access to it
if ($totalRows_rsSAUserNavBars != 0 || ($totalRows_rsCheckEmpty == 0 && $row_rsSANavBars['NavBarId'] == '112')) {
$NavBarsExist = true; ?>
<li<?php if($row_rsSANavBars['LinkURL'] == $page){echo ' class="current_sub"';} ?>><a href="<?php echo $row_rsSANavBars['LinkURL'] ?>" class="blackRed"><?php echo $row_rsSANavBars['Name']; ?></a></li>
<?php
}
}
}
if ($totalRows_rsSANavBars == 0 || !$NavBarsExist)
echo '<li><a href="#">not available</a></li>'; ?>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li>
</ul>
<ul class="adminnav two"><li><a href="#?current=one&sub=none"><b>Account Management</b><!--[if IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
<ul class="sub">
<?php
does this look better - barring the horrible variable names?
Bookmarks