I'm thinking this should be simple but I'm stumped!
background:
order form with repeating element areas 1) Item: select/option 2) Quantity: input
I have a query which returns the result I want to display in area 1) which is a list of products.
I tried to setup a loop to populate the select/option with the same list as many times as needed - 4X with option to show 15x with each Item/Quantity line named with the increment of the loop.
ie. product1, quantity1
Product2, quantity2
...etc.
When I load the page containing the form, the first select/option displays the full list of product, each further iteration displays no data.
Why does the result set work only once and how can I achieve more than one line of form elements loaded with the desired data?
And is numbering each line a workable way to label the form data for processing later? Or is there a smarter way to pass that data for inserting into the database to transaction-related tables?
I've included some snips to illustrate:
PHP CODE
for ($selectP = 1; $selectP<5; ++$selectP) {
echo ("TESTLOOP Select Product: <select name=\"orderProduct$selectP\">
<option>Select an Incentive Product</option>");
while (($prow = mysql_fetch_array($resultGetIncentiveProducts))){
print("<option");
print(">$prow[2]</option>\n");
} // end while
echo("</select></br>");
echo "Quantity: <input type=\"text\" size=\"5\" name=\"productQuantity$selectP\"></br>";
} // end for
the HTML Source
TESTLOOP Select Product:
<select name="orderProduct1">
<option>Select an Incentive Product</option>
<option>Polo shirt Large</option>
<option>Tshirt Large</option><option>Tshirt Small</option>
<option>Tshirt XXLarge</option>
</select>
<br>Quantity: <input size="5" name="productQuantity1" type="text"><br>
TESTLOOP Select Product: <select name="orderProduct2"><option>Select an Incentive Product</option></select><br>Quantity: <input size="5" name="productQuantity2" type="text"><br>
TESTLOOP Select Product: <select name="orderProduct3"><option>Select an Incentive Product</option></select><br>Quantity: <input size="5" name="productQuantity3" type="text"><br>
TESTLOOP Select Product: <select name="orderProduct4"><option>Select an Incentive Product</option></select><br>Quantity: <input size="5" name="productQuantity4" type="text"><br>
Any help with a good way to achieve the desired results will be appreciated greatly.
It doesn't seem efficient to need a different query and result set for each different (up to 15!) select/option box.
Kris O.