Select Page
Poker Forum
Over 1,292,000 Posts!
Results 1 to 5 of 5
  1. #1

    Default php

    I don't really know php, just plugging in what makes sense from my c/c++ history.

    I have a form that is created and then populated based off specific values in a db.

    I want the user to be able to edit those values, and submit them and then have those values updated in the db.

    I can get the first part done...

    but I can only get the second part done by posting every single variable as its own entity. I would much rather send across the values and run it through a for statement, but I don't believe the post syntax allows for that.

    Lets say the posted form field name is

    postedname1
    postedname2
    postedname3

    and so on...

    to get it to work I have to say...

    $value[0] = $_POST['postedname1'];
    $value[1] = $_POST['postedname2'];
    $value[2] = $_POST['postedname3'];
    etc...

    I would rather run it something like this...


    for($location=0;$location<16;$location++){
    $value[$location] = $_POST['postedname$location'];
    }

    The formatting of that is obviously incorrect as it doesn't work, but how can I change the value of the post value to equal 'postedname1','postedname2' as the for statement goes up?

    Anyone....Anyone...bueller...
    20K06 - 20k profit by end of 2006
    Progress at http://www.crunchy-in-milk.com
  2. #2
    Try this

    for($location=0;$location<16;$location++){
    $value[$location] = $_POST['postedname'.$location];
    }

    Concatenate the $location variable rather than sticking it within the quotes. This will work, i had to do something similar in a crunch on a recent project.
  3. #3
    just out of curiosity why are you not using postedname[] -- i.e. an array -- in the form?
  4. #4
    TylerK's Avatar
    Join Date
    Oct 2004
    Posts
    1,870
    Location
    PEANUT BUTTER JELLY TIME

    Default Re: php

    Quote Originally Posted by Jeebus Kliest
    Lets say the posted form field name is

    postedname1
    postedname2
    postedname3
    Age <input type="text" name="postedname[]">
    Sex<input type="text" name="postedname[]">
    Location<input type="text" name="postedname[]">

    Quote Originally Posted by Jeebus Kliest
    for($location=0;$location<16;$location++){
    $value[$location] = $_POST['postedname$location'];
    }
    for($i = 0; $i < count($_POST['postedname']); $i++) {
    print $_POST['postedname'][$i];
    }
    TylerK: its just gambling if i want to worry about money i'll go to work lol
  5. #5
    Since postedname is the name of the input box, I wasn't sure if it would allow it to be a variable in the html form itself.

    Anyways thanks thirteen that was what I needed. I knew it was a stupid simple syntax error...would help to actually know the language but can get by. Now since that was basically the only thing holding me back I can finish the entire project.
    20K06 - 20k profit by end of 2006
    Progress at http://www.crunchy-in-milk.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •