0
if(isset($_POST['update']))
    {

        $sql = "UPDATE menus SET Menu_bar = '$_POST[menu_bar]' WHERE ID = '$_POST[hidden]'";
        mysql_query( $sql, $con );
    }

    $resultMainMenu = mysql_query("SELECT * FROM menus WHERE Parent_id=0 ") or die(mysql_error());

    echo '<ul>';


    while($row = mysql_fetch_array($resultMainMenu))
    { 
        echo '<form action=page.php method=post>';
            echo '<li>' . '<input type=submit name=update value=update>' .'<input type=hidden name=hidden value=' . $row['ID'] . '>'  . ' <input type=text name=menu_bar value=' . $row['Menu_bar'] . '>' .'<br/>'; // echo main menu 
            $resultSubmenu = mysql_query("SELECT * FROM menus WHERE Parent_id=" . $row['ID']) or die(mysql_error());
            echo '<ul>';
                while($rowSub = mysql_fetch_array($resultSubmenu))
                {
                    echo '<li>' .'<input type=submit name=update value=update>' .' '.'<input type=hidden name=hidden value=' . $rowSub['ID'] . '>' . '<input type=text name=menu_bar value=' . $rowSub['Menu_bar'] .'>' . '<br/>' .'</li>'; // echo sub menu
                }
                echo '</ul>';

            echo '</li>';
            echo '</form>';
    }
    echo'</ul>';

Edited by blueberry25: insufficient details

1
Contributor
1
Reply
12
Views
2 Years
Discussion Span
Last Post by blueberry25
0

I've tried to fix this since yesterday but I can't figure it out. My code is only updating the last record (the menus with no sub-menus or the last sub-menu of a menu) and not all of them as it should. Help please !

This topic has been dead for over six months. 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.