PHP writes javascript, but javascript cannot write PHP. If you want a dynamic form, you will need to instruct PHP to provide ALL the variables and load them on the client via javascript, then have javascript build and submit the form when the client makes his final choice. PHP can then accept the submitted form and parse it accordingly.
Of course, clients with javascript disabled will not be able to view it and something that complex is bound to run into version conflicts on some browsers.