0
<ul class="sf-menu">
    <?php
            $menu_query  ="SELECT * ";
            $menu_query .="FROM `menu`";
            $menu_query .="WHERE `Status` = 'Enabled'";
            $menu_query .="AND `ParentMenuID` = '0'";
            $menu_result = mysqli_query($connection,$menu_query);
              while($row = mysqli_fetch_array($menu_result,MYSQLI_ASSOC)){
                    $PageID=$row['PageID'];
                    $ID=$row['ID'];
                    $LW=$row["LinkWidth"];

                    $menu_qry_for_page  ="SELECT * ";
                    $menu_qry_for_page .="FROM `page`";
                    $menu_qry_for_page .="WHERE `ID` = '$PageID'";

                    $menu_qry_for_sub  ="SELECT * ";
                    $menu_qry_for_sub .="FROM `menu`";
                    $menu_qry_for_sub .="WHERE `Status` = 'Enabled' ";
                    $menu_qry_for_sub .="AND `ParentMenuID` = '$ID'";

                    if(isset($LW) == 'otherlink'){
                        $menu_url=$row["OtherUrl"];
                        $menu_name=$row["MenuName"];
                    }
                    if($LW == 'page'){
                        $menu_result_qry = mysqli_query($connection,$menu_qry_for_page);
                        while($row_for_page= mysqli_fetch_array($menu_result_qry,MYSQLI_ASSOC)){
                            $menu_name = $row_for_page["Title"];
                            $menu_url = $row_for_page["Slug"];
                        }
                    }

                    echo "<li class=\"item4\"><a href=\"$menu_url\">$menu_name</a>";
                    $sub_menu_result = mysqli_query($connection,$menu_qry_for_sub);
                    while($row_for_sub = mysqli_fetch_array($sub_menu_result,MYSQLI_ASSOC)){
                        $linkWidth = $row_for_sub['LinkWidth']; 
                        $Page_ID = $row_for_sub['ID'];
                        $parentMID = $row_for_sub['ParentMenuID'];
                        if(isset($linkWidth) == 'otherlink'){
                            $url_name = $row_for_sub['MenuName'];
                            $url = $row_for_sub['OtherUrl'];
                        }
                        if($linkWidth == 'page'){
                            if($menu_row_qry = mysqli_query($connection,$menu_qry_for_page)){
                                while($row_qry_page= mysqli_fetch_array($menu_row_qry,MYSQLI_ASSOC)){
                                    $url_name = $row_qry_page["Title"];
                                    $url = $row_qry_page["Slug"];
                                }
                            }
                        }
                        echo "<ul>";
                        if($parentMID = $ID){
                            echo "<li><a href=\"$url\">$url_name</a></li>";
                        }
                        echo "</ul>";                            
                        echo"</li>";                 
                    }
                }
    ?>
                </ul>

only 1 sub menu shown why :?
need help ?
thanks in advance

3
Contributors
4
Replies
26
Views
2 Years
Discussion Span
Last Post by rjusman90
0

Try putting "return;" at the end of the echo statements after line 54. It could be the that the script is prematurely exiting the execution of the entire script instead of just the first part.

Untested... just a suggestion that you might try.

0

Try putting "return;" at the end of the echo statements after line 54. It could be the that the script is prematurely exiting the execution of the entire script instead of just the first part.Untested... just a suggestion that you might try.

:( this is not working

0

Some suggestion...

1) If you are searching for a string in a query and expect case-insensitive, use the key word like instead of assignment symbol (i.e. WHERE Status like 'Enabled').
2) Line 22, if(isset($LW) == 'otherlink'){ will never be true because isset() doesn't return a string to compare with the value you are trying to. The same thing happens on line 40.
3) Your database call is not safe because there is no handle for failing to connect/call.
4) When you ask a question like this, remember to give a set of sample input and expected set of output. Throwing the whole script to let others figuring it out is not practical.

Edited by Taywin

0

Some suggestion...

1) If you are searching for a string in a query and expect case-insensitive, use the key word like instead of assignment symbol (i.e. WHERE Status like 'Enabled').
2) Line 22, if(isset($LW) == 'otherlink'){ will never be true because isset() doesn't return a string to compare with the value you are trying to. The same thing happens on line 40.
3) Your database call is not safe because there is no handle for failing to connect/call.
4) When you ask a question like this, remember to give a set of sample input and expected set of output. Throwing the whole script to let others figuring it out is not practical.

this is done
but sub menu havn't change :(

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.