php dynamic variables from one webpage to another

Posted on 2004-11-16
Medium Priority
Last Modified: 2008-03-06
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:
for ($indivstockitemscheck=1;$indivstockitemscheck<=$indivstockitems;$indivstockitemscheck++)

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


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)

Anyone got any ideas at all please?


Question by:daryn
LVL 48

Assisted Solution

hernst42 earned 400 total points
ID: 12597567
why not use

Then $_POST["itemdesc"] will be an array automaticly (done by PHP) with that entred values

Accepted Solution

mattjp88 earned 600 total points
ID: 12598137
ok, add this to the first page:

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

and for the second page:

if ($noItems>0) {
$itemArray=new Array();
for ($i=0;$i<$noItems;$i++){

echo "<pre>";
echo "</pre>";


Author Comment

ID: 12613725
thanks very much, situation resolved.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question