Creation of 8 variables with unique HTML tags based on user selection

advertisements

I've come across a problem and I don't know how I should approach it.

I want to have the user of my website able to pick from a selection of 5 things, say for example;

Cars, Trains, Planes, Snowmobiles, ATVs.

Based on their selection, it will redirect to a page with the variable ?choice=cars in the URL (this part I know how to do.) For example configure_choice.php?choice=cars

Then, upon visiting this page, I want to generate 8 dropdown boxes, each of which have a different HTML identifier. Note that these dropdown boxes VARY depending on the choice.

So, if they chose cars, I would want:

<select name="car1" class="dropdown">
<option>Chevrolet</option>
<option>GM</option>
<option>Cadillac</option>
</select>

<select name="car2" class="dropdown">
<option>Chevrolet</option>
<option>GM</option>
<option>Cadillac</option>
</select>

<select name="car3" class="dropdown">
<option>Chevrolet</option>
<option>GM</option>
<option>Cadillac</option>
</select>

... and so on, all the way to 8.

I thought about assigning something like

for($j = 1, $j <= 8, ++$j)
{
$car_dropdown_$j = "<select name=""car" . "$j"" class="dropdown">
    <option>Chevrolet</option>
    <option>GM</option>
    <option>Cadillac</option>
    </select>";

echo $car_dropdown_$j;
}

But when I try to run this loop, I get the following error:

Parse error: syntax error, unexpected ')', expecting ';' in C:\web\encodetest.php on line 5

And I also don't know if you can put a variable inside the HTML tag like that and have it work properly.

Basically I'm trying to set up 8 variables that I can just plop in my HTML somewhere with and have the dropdown boxes be unique, so when sent off to MySQL, they can be identified. Any help here?

Thanks so much!


for($j = 1; $j <= 8; $j++) //goodeye adam catching the ;
{
$car_dropdown[$j] = "<select name='car" . $j . "' class=\"dropdown\">
    <option>Chevrolet</option>
    <option>GM</option>
    <option>Cadillac</option>
    </select>";

echo $car_dropdown[$j];
}