So let me summarize really briefly...
<ol>
<li>you create dynamically a drop down menu
<li>you want to select a value from this menu and based on what value selected you have another drop down menu that pops up.
<li>you want to use $PHP_SELF to get that done
</ol>
I am not going to type the code, but I will give you a conceptual model.
<hr>
First thing you need to do is what you did - create script to dynamically generate the first form. In the last line of the form where you have your submit button you need to name it <input type=submit value=Click <b>name=enter</b>>. Of course the first line will be <form method=post action=$PHP_SELF>. You will also have to name the select tags <select name=choice>, we will use it in switch statement.
<b>Note:</b> The above script has to be in a lower part of the file, because the processing sript will be located in the upper part of the file.
Now the processing sript.
if($enter)
{
switch($choice) \
{
below you type all the choices available from your first form.
case 1:
Here you inlude the first drop down menu form
break;
case 2:
Here you include the second dro down menu form
break;
and etc.
}
To simplify this whole process I suggest that you write a class, which will make things simpler and updating code will be much easier.
For example:
if($enter)
{
include("dropdownclass.php");
$obj=new Class; \whatever the name of your class
and then
you do this:
switch($choice)
{
case 1:
$obj->form1; \instead of typing the whole form you just call it from the class
break;
case 2:
$obj->form2;
break;
etc.
}
This is just a concept, but... every single methodology is built upon a logical model, so the rest is up to you.
Hope that helped,
Di