Input data to fields in array?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oeln

    #1

    Input data to fields in array?

    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_cn t; $cnt++) {
    echo "<input type=\"text\" name=\"input.$c nt\">";
    }

    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($in put); $cnt++) {
    $input[$cnt] = $_POST['input'.$cnt];
    }

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

    for($out=1; $out<=count($in put); $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..
  • michaeln

    #2
    Re: Input data to fields in array?

    Oeln wrote:
    [color=blue]
    > 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_cn t; $cnt++) {
    > echo "<input type=\"text\" name=\"input.$c nt\">";
    > }
    >
    > 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($in put); $cnt++) {
    > $input[$cnt] = $_POST['input'.$cnt];
    > }
    >
    > I get nothing in output though if I then include this:
    >
    > for($out=1; $out<=count($in put); $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..[/color]

    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.



    -Michael

    Comment

    Working...