How to make a dynamic menu with a dependent sub-menu?

Yes, that’s exactly what you want to look at. You can capture the “select” event from the first menu, and use that to call your PHP code to return the entries for your sub-menu. You can extract stuff like the user id from your page, and pass that (along with the main menu selection) to your PHP to tailor it as you need it. Your PHP code will just echo the html for the sub-menu options, and your Ajax success() function can insert them.

Have a look at the code in this topic in case it helps, it has a main menu and two levels of sub-menu below it: AJAX and Php not keeping values between my drop downs - #3 by johannesmoolman - yours will be simpler with the single sub-menu level.