Results 1 to 3 of 3

Thread: form data to array?

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2002
    Location
    Singapore
    Posts
    32

    form data to array?

    suppose i have a form, then the fields are generated dynamically (because each user can generate any number of fields in a new table and i read the fields from that table and put it in the form)

    So, how do i put that form data into an array, because the field names are done by the user and i won't have any idea what they are.

    thanks!
    C you, C me

  2. #2
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    you have the names of the form elements don't ya? well then that is all you need to put the values in the array. when they submit the form just tke those names and insert the values form the form into the array and then you can do what youwant with them.

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: form data to array?

    Originally posted by Zhiquan
    suppose i have a form, then the fields are generated dynamically (because each user can generate any number of fields in a new table and i read the fields from that table and put it in the form)

    So, how do i put that form data into an array, because the field names are done by the user and i won't have any idea what they are.

    thanks!
    Give this a try. It'll cycle through each $_POST variable and give you the name and value:

    Code:
    while (list($var, $value) = each ($_POST)) {
        echo "$var = $value<br>\n";
    }
    If your have pre PHP 4.1.0, use $HTTP_POST_VARS instead of $_POST.

    Hope this helps.
    My evil laugh has a squeak in it.

    kristopherwilson.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
  •  



Click Here to Expand Forum to Full Width