Ok.
PHP delivers HTML to the browser. The script is run at the server-side. You cannot run PHP on the client-side (the user's browser).
So, if you want to 'build' a 2nd Select Box, that depends on a 1st Select Box then there are two possibilities:
I assume that you are selecting an item in the 1st box and then clicking a button to 'accept' the choice. Also, the both select boxes are elements of a form.
You could do ....
1) Use javascript (client-side script) to update/display the 2nd select box.
Or ...
2) Submit the form back to the current page, along with the value in the 1st select box, and redraw the page ... including the appropriate 2nd Select Box.