By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,828 Members | 1,409 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,828 IT Pros & Developers. It's quick & easy.

Input data to fields in array?

P: n/a
I've got the following issue: in one form (1.php), I get the number of
inputs to offer, $input_cnt (it could be from 1-10, for example). In a
for loop, I then offer that number of input fields in the next form
(2.php):

for($cnt=1; $cnt<=$input_cnt; $cnt++) {
echo "<input type=\"text\" name=\"input.$cnt\">";
}

I get, for example, 'input.1', 'input.2', 'input.3', etc.

The issue I've got is getting this data back, once it's input to
fields I've offered in that form (3.php). I'd imagine it would be like
this, for example:

for($cnt=1; $cnt<=count($input); $cnt++) {
$input[$cnt] = $_POST['input'.$cnt];
}

I get nothing in output though if I then include this:

for($out=1; $out<=count($input); $out++) {
echo "$input[$out]";
}

I get no error, either. I'm not certain where the issue is; but I've
been getting nowhere with it on my own. I'd be grateful for any
insights..
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Oeln wrote:
I've got the following issue: in one form (1.php), I get the number of
inputs to offer, $input_cnt (it could be from 1-10, for example). In a
for loop, I then offer that number of input fields in the next form
(2.php):

for($cnt=1; $cnt<=$input_cnt; $cnt++) {
echo "<input type=\"text\" name=\"input.$cnt\">";
}

I get, for example, 'input.1', 'input.2', 'input.3', etc.

The issue I've got is getting this data back, once it's input to
fields I've offered in that form (3.php). I'd imagine it would be like
this, for example:

for($cnt=1; $cnt<=count($input); $cnt++) {
$input[$cnt] = $_POST['input'.$cnt];
}

I get nothing in output though if I then include this:

for($out=1; $out<=count($input); $out++) {
echo "$input[$out]";
}

I get no error, either. I'm not certain where the issue is; but I've
been getting nowhere with it on my own. I'd be grateful for any
insights..


http://www.php.net is a great place to look when you don't know how to do
something or do not understand something in PHP

The answer to your question is on the bottom of this page before the user
comments.

http://www.php.net/manual/en/languag...s.external.php

-Michael
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.