Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6540211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:57:03+00:00 2026-05-25T10:57:03+00:00

I am having a problem with making the links in my bar work properly

  • 0

I am having a problem with making the links in my bar work properly the database is setup like so my db http://bloodkittens.com/resources/upload/db.png

<?php 
error_reporting(E_ALL);
ini_set('display_errors', '1');

mysql_connect("localhost", "dbuser", "******");
mysql_select_db("guild");

// prepare special array with parent-child relations
$menuData = array(
'items' => array(),
'parents' => array()
);
$result = mysql_query("SELECT  id_menu id, parentID_menu parentId, label_menu name FROM main_menu` ORDER BY parentID_menu"); 

while ($menuItem = mysql_fetch_assoc($result))
{
$menuData['items'][$menuItem['id']] = $menuItem;
$menuData['parents'][$menuItem['parentId']][] = $menuItem['id'];
}

// menu builder function, parentId 0 is the root
function buildMenu($parentId, $menuData)
{
$html = '';
$parent='';

if (isset($menuData['parents'][$parentId]))
{
    $menuClass= ($parentId==0) ? ' class="navbar" id="navbar"' : '';
    $parent= ($parentId==0) ? 0 : 1;    
    $html = "<ul{$menuClass}>\n";

    foreach ($menuData['parents'][$parentId] as $itemId)
    {
        //subment
        $result=mysql_query("select * from main_menu where parentID_menu='$itemId'");
        if (mysql_num_rows($result)>(int)0 && $parentId!=0) {
            $subm  =' class="navbar"';
        }else{
           $subm  ='';
        }
        //end

        $menu = $parentId == 0 ? ' class="menulink"' : '';      //class of main menu
        $html .= '<li>' . "<a{$subm}{$menu} href=\"#\" >{$menuData['items'][$itemId]['name']}</a>";

        // find childitems recursively
        $html .= buildMenu($itemId, $menuData);

        $html .= '</li>';
    }
    $html .= '</ul>';
}

return $html;
}

// output the menu
echo buildMenu(0, $menuData);
?>

How would i make it so that the value link_menu would be the href in the code for each separate entry in the db? rather then \’#\’ because the code works completely and i’m very happy how it looks after i apply my css to it but the links aren’t working

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:57:04+00:00Added an answer on May 25, 2026 at 10:57 am

    the code that i used was in the end like this i think i got it to work by pure luck but regardless i win : )

    <?php 
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    
    mysql_connect("localhost", "BloodKittens", "Zangoshi1");
    mysql_select_db("bloodkittens");
    
    // prepare special array with parent-child relations
    $menuData = array(
    'items' => array(),
    'parents' => array(),
    'links' => array()
    );
     $result = mysql_query("SELECT id_menu id, parentID_menu parentId, label_menu name,  link_menu link FROM main_menu ORDER BY parentID_menu");
    
    while ($menuItem = mysql_fetch_assoc($result))
    {
    $menuData['items'][$menuItem['id']] = $menuItem;
    $menuData['parents'][$menuItem['parentId']][] = $menuItem['id'];
    $menuData['links'] = $menuItem['link'];
    }
    
    // menu builder function, parentId 0 is the root
    function buildMenu($parentId, $menuData)
     {
    $html = '';
    $parent='';
    
    if (isset($menuData['parents'][$parentId]))
    {
        $menuClass= ($parentId==0) ? ' class="navbar" id="navbar"' : '';
        $parent= ($parentId==0) ? 0 : 1;    
        $html = "<ul{$menuClass}>\n";
    
        foreach ($menuData['parents'][$parentId] as $itemId)
        {
            //subment
            $result=mysql_query("select * from main_menu where parentID_menu='$itemId'");
            if (mysql_num_rows($result)>(int)0 && $parentId!=0) {
                $subm  =' class="navbar"';
            }else{
               $subm  ='';
            }
            //end
    
            $menu = $parentId == 0 ? ' class="menulink"' : '';      //class of main menu
            $html .= '<li>' . "<a{$subm}{$menu} href=\"{$menuData['items'][$itemId]['link']}\" >{$menuData['items'][$itemId]['name']}</a>";
    
            // find childitems recursively
            $html .= buildMenu($itemId, $menuData);
    
            $html .= '</li>';
        }
           $html .= '</ul>';
       }
    
       return $html;
     }
    
    // output the menu
    echo buildMenu(0, $menuData);
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
Been having a problem making a jQuery slider, I have a list of links
I'm having some difficulties with the following problem: I'm making a little game where
We're having problem with a huge number of legacy stored procedures at work. Do
I'm having problem with Rails plugin attachment_fu . On every upload, I get validation
I'm having a little bit of trouble making OpenID work from within an iframe.
I am making a basic shopping cart and i'm having a problem where in
The section Last links in the chain: Stashing and the reflog in http://ftp.newartisans.com/pub/git.from.bottom.up.pdf recommends
I am having a problem making a window appear programmatically..... I have created the
I'm making my first Android application and I'm having a problem for which I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.