Results 1 to 3 of 3

Thread: get number of elements in POST

  1. #1

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945

    get number of elements in POST

    I have a page where a user will be entering numbers into text boxes. The number of textboxes will vary, and I need to update a database with the values entered in these boxes.

    So is there a way to determine how many values are being passed in the POST method?

    something like:
    PHP Code:
    While($check==1)
    {
    $box=databox$i;
    if(
    $_POST[$box]!="")
    {
     
    /// run SQL query to update DB for that value
    }
    else
      
    check=0;
    $i++;

    Something close to that... !?
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Something like this will loop $_POST:

    Code:
    foreach ($_POST as $key => $value) {
       echo "$_POST['$key'] = $value<br />";
    }
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    If you give the textboxes in the form names like
    <input type="text" name="txtbox[0]" />
    you can retrieve the count of them in PHP with a simple
    Code:
    <?php echo count($_POST['txtbox']); ?>
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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