Jump to content

Recommended Posts

I wrote the following code in php but when i click on the node, the link ;doesn't work

<?php
    function get_menu_tree($parent_id) 
    {
    global $conn;
    $menu = "";
    //$sqlquery = " SELECT linkpage,moduleid,menuid,menuname,parentid,menudisplay FROM admnmenumaster where menudisplay='Y' and parentid='" .$parent_id . "' ";
    $sqlquery = " SELECT linkpage,moduleid,menuid,menuname,parentid,menudisplay FROM admnmenumaster where menudisplay='Y' and parentid='" .$parent_id . "' ";
    
    $result=sqlsrv_query($conn,$sqlquery);
    while($row = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC))
    {
          $menu .="<li class=treeview><a href='".$row['linkpage']."'>".$row['menuname']."</a>";
                    $menu .= "<ul class=treeview-menu>".get_menu_tree($row['menuid'])."</ul>"; //call  recursively
          $menu .= "</li>";
 //echo "HELLO<a href=$row[linkpage]>$row[menuname]</a>";
    }
   
    return $menu;
} 
    ?>
    <?php echo get_menu_tree(0); //start from root menus having parent id 0 ?>

 

Edited by requinix
please use the Code <> button when posting code
Link to comment
https://forums.phpfreaks.com/topic/311389-treeview-in-php/
Share on other sites

What does the generated HTML look like (Use the "View Source" tool in your browser).  

Remember that your PHP is effectively just building a String that gets sent to the browser for it to make sense of. 

Copy the link URL out of the browser and make sure that that it works on its own.  It may simply be that $row['linkpage'] isn't a valid URL. 

Regards, 
   Phill  W.

 

 

Link to comment
https://forums.phpfreaks.com/topic/311389-treeview-in-php/#findComment-1580975
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.