Passing an array using a hidden input tag on a form
Posted: Tue Jul 02, 2002 7:32 am
I wish to pass a variable containing an array using an input tag of type hidden on a form.
1. I create a variable containing the number of results and an array containing product ids.
I have tested the array has the values I expect...
2. I include the variables on a form using an input tag type hidden.
3. In the response document I attempt to display the values in the array.
Whilst the loop cycles the correct number of times the variable only seems to return the word array and not the values.
Any assistance in resolving this problem will be greatly appreciated.
- Andrew
1. I create a variable containing the number of results and an array containing product ids.
Code: Select all
$numresults = mysql_num_rows($result);
while ($product = mysql_fetch_assoc($result))
{
$idvalue = array($productї"id"]);
$idarray = array_merge($idarray, $idvalue);
}2. I include the variables on a form using an input tag type hidden.
Code: Select all
echo "<INPUT type="hidden" name="numresults" value="$numresults">";
echo "<INPUT type="hidden" name="idarray" value="$idarray">";Code: Select all
for ($i=0; $i<$numresults; $i++)
echo "$idarrayї$i], ";Any assistance in resolving this problem will be greatly appreciated.
- Andrew