Link to home
Start Free TrialLog in
Avatar of daryn
daryn

asked on

php dynamic variables from one webpage to another

Hi there.

I've got a problem with php. In one html page, I have a stock entry list where there is an dropdown box to state how many seperate items there are with some code lookin like this:
<?php
for ($indivstockitemscheck=1;$indivstockitemscheck<=$indivstockitems;$indivstockitemscheck++)
{
?>

<tr>
<td><font face="arial" size="2"><h3>Batch item #<?php echo $indivstockitemscheck; ?></h3></font></td>
</tr>
<tr>
<td><font face=arial size=2><b>Description:</b></td>
<td><input type="text" size=60 name="itemdesc<?php echo $indivstockitemscheck; ?>"></td>
</tr>

<?php
}
?>

This creates a list of variables like itemdesc1, itemdesc2, itemdesc3 as many itemdesc iterations as the user wishes.

This works fine.

The problem starts when the form is submitted to another php page that has to interpret the _POST variables.
I dont know how to assign variable names to the itemdesc range of variables, ie, this doesnt work:

while ($i<$noofitems)
{
$itemdesc[$i]=$_POST["itemdesc$i"];
$i++;
}

Anyone got any ideas at all please?

thanks

Daryn
SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of daryn
daryn

ASKER

thanks very much, situation resolved.