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 8584463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:46:48+00:00 2026-06-11T21:46:48+00:00

I have the following code: function menu($parent, $level){ global $dbc; $result = $dbc->prepare(‘SELECT linktext,

  • 0

I have the following code:

function menu($parent, $level){
global $dbc;

$result = $dbc->prepare('SELECT linktext, visible, sort FROM content WHERE parent =? ORDER BY sort');
$result->bind_param('s', $parent);
$result->execute();
$result->bind_result($menu_linktext, $menu_visible, $menu_sort);  
$total_records = $result->num_rows;

if($level > 0 && $total_records > 0){
echo '<ul>';
}
while($row = $result->fetch()){
echo "<li>";
echo '<a href="?page=' . $menu_linktext . '">' . $menu_linktext . '</a>'.$id;
//display this level's children
menu($id, $level+1);
echo "</li>\n";
}
if($level > 0 &&  $total_records > 0){
echo '</ul>';
 }
}
echo '<ul>' . menu(0,0) . '</ul>'

It works for one link (Home) then throws out a Call to a member function bind_param() on a non-object error.

The basics of the table is:

page | linktext | visable | parent | sort
  1       Home       1         0      1
  2      Gallery     1         0      3
  3     About Us     1         0      2
  4    Contact Us    1         0      5
  5     Services     1         0      4
  6     Diving       0         5      1
  7     Angling      0         5      2
  8     Charters     0         5      3

Here is the HTML structure:

 <ul class="sf-menu" id="nav">
          <li><a href="index.html">Home</a></li>
          <li><a href="about.html">Examples</a></li>
          <li><a href="gallery.html">A Page</a></li>
          <li><a href="#">Services</a>
            <ul>
              <li><a href="#">Diving</a></li>
              <li><a href="#">Angling</a>
              <li><a href="#">Charter</a></li>
            </ul>
          </li>
          <li><a href="contact.html">Contact Us</a></li>
        </ul>

I want to get the basic menu working then work on the sort order of the links.If anyone can help it would be very much appreciated.

  • 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-06-11T21:46:49+00:00Added an answer on June 11, 2026 at 9:46 pm

    Problem solved! I will post how it was done and someone may be able to use it.

    function menu()
      {
        global $dbc;
    
      $result = $dbc->prepare('SELECT page, linktext, visable, parent FROM content WHERE visable > 0 ORDER BY parent,sort ASC');
      $result->execute();
      $result->bind_result($menu_page, $menu_linktext, $menu_visible, $menu_parent);
    
      while($result->fetch())
        {
            if($menu_parent == 0) $menu[$menu_page]=$menu_linktext;
            elseif(!empty($menu[$menu_parent])) $sub[$menu_parent][]=$menu_linktext;
        }
    
      $result->close();
    
      if(!empty($menu))
        {
            echo '<ul class="sf-menu" id="nav">';
            foreach($menu as $page=>$link)
              {
                  echo "<li><a href='$link'>$link</a>";
                  if(!empty($sub[$page]))
                    {
                        echo '<ul>';
                        foreach($sub[$page] as $lnk) echo "<li><a href='$lnk'>$lnk</a></li>";
                        echo '</ul>';
                    }
                  echo '</li>';
              }
            echo '</ul>';
          }
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: function isValidAuthor($authorID){ $query = SELECT * FROM jos_users WHERE
I currently have the following js code function clearMulti(option) { var i; var select
I have the following code: $(li.item).live('click',function() { $('#menu').animate({ }, 500); }); Now, I would
I have the following jQuery code: $(ul.menu li a).click(function() { $(ul.menu li a).removeClass(currentMenu); $(this).addClass(currentMenu);
I have the following jQuery code: $('#menu .selected').removeClass('selected'); $('#homel').addClass('selected'); $('#home').slideDown(150, function() { $('#public').slideUp(200); $('#login').slideUp(200);
I have a dropdown menu working great with the following code: $('#menu ul li').mouseenter(function(){
I have the following code which work fine: $('.ui-selectmenu-menu a').click(function() { alert('OK'); }); However,
I have the following code for my popup menu, the parent link is the
I have following code snippet: $(document).ready( function() { $(#input1).contextMenu({ menu: 'myMenu' }, function(action, el,
So, I have the following code: $(.btn-slide-1).click(function(){ $('div[id^=panel]').slideUp(slow); $('ul#menu li a').removeClass(active); $(#panel-about).slideToggle(slow); $(this).toggleClass(active); return

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.