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
darynAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hernst42Commented:
why not use
name="itemdesc[]"

Then $_POST["itemdesc"] will be an array automaticly (done by PHP) with that entred values
0
mattjp88Commented:
ok, add this to the first page:

<input type=hidden name=noItems value="<?PHP echo $indivstockitems; ?>">

and for the second page:

<?PHP
$noItmes=$_POST['noItems'];
if ($noItems>0) {
$itemArray=new Array();
for ($i=0;$i<$noItems;$i++){
$itemArray[$i]=$_POST['itemdesc'.$i];
}
}

echo "<pre>";
print_r($itemArray);
echo "</pre>";

?>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
darynAuthor Commented:
thanks very much, situation resolved.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.