Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. How to iterate form-fields on a page and send them to database? [modified]

How to iterate form-fields on a page and send them to database? [modified]

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
databasehelpquestioncsharpphp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jasonmp
    wrote on last edited by
    #1

    I am trying to submit a form on my page. It's proving to be a very difficult and frustrating task. The problem is that there is no way of telling how many 'fields' will need to be submitted. The user might add 50 products to the cart, and make 30 changes to the quantities, or they might add 600 products to the cart and make 599 changes to the quantities (you never know), and with this website, the client is expecting high volume of sales so I need to be prepared for cases such as that. I have a Table (a script that I bought) which has its own form tag for the data inside the table, however it uses GET not POST. And I am using:

    foreach($_GET['items'] as $p=>$q)
    {
    // Update in database. This sql query has been tested, so I know it works, which means that the problem lies within the foreach loop, since it only stopped working when I added the foreach loop to update all form fields.
    }

    But I dont know how to do this. I have tried hundreds of variations of the above snip and NOTHING has worked for me. I have searched all ovver php.net, google and am out of ideas, and would greatly appreciate anyone's advice or help. How can I update ALL form fields to the database? Thanks Edit: The result of

    print_r($_GET);

    is: Array ( [ct_items_per_page] => 10 [ct_sort] => t_t_t_t [ct_page] => 1 [ct_search] => [ct_items_per_page_change] => all [ct_multiple_search] => Array ( [0] => [1] => [2] => [3] => ) [product] => M5 x 1 MTR Allthread (Grade 304 Unit Price) [items] => Array ( [1] => 45 ) ) Edit: What else would work in my situation? Does anyone have any links/tutorials/articles? I cannot find anything anywhere. Are there other ways to submit all fields to a database?

    modified on Monday, March 28, 2011 1:18 AM

    C 1 Reply Last reply
    0
    • J jasonmp

      I am trying to submit a form on my page. It's proving to be a very difficult and frustrating task. The problem is that there is no way of telling how many 'fields' will need to be submitted. The user might add 50 products to the cart, and make 30 changes to the quantities, or they might add 600 products to the cart and make 599 changes to the quantities (you never know), and with this website, the client is expecting high volume of sales so I need to be prepared for cases such as that. I have a Table (a script that I bought) which has its own form tag for the data inside the table, however it uses GET not POST. And I am using:

      foreach($_GET['items'] as $p=>$q)
      {
      // Update in database. This sql query has been tested, so I know it works, which means that the problem lies within the foreach loop, since it only stopped working when I added the foreach loop to update all form fields.
      }

      But I dont know how to do this. I have tried hundreds of variations of the above snip and NOTHING has worked for me. I have searched all ovver php.net, google and am out of ideas, and would greatly appreciate anyone's advice or help. How can I update ALL form fields to the database? Thanks Edit: The result of

      print_r($_GET);

      is: Array ( [ct_items_per_page] => 10 [ct_sort] => t_t_t_t [ct_page] => 1 [ct_search] => [ct_items_per_page_change] => all [ct_multiple_search] => Array ( [0] => [1] => [2] => [3] => ) [product] => M5 x 1 MTR Allthread (Grade 304 Unit Price) [items] => Array ( [1] => 45 ) ) Edit: What else would work in my situation? Does anyone have any links/tutorials/articles? I cannot find anything anywhere. Are there other ways to submit all fields to a database?

      modified on Monday, March 28, 2011 1:18 AM

      C Offline
      C Offline
      cjoki
      wrote on last edited by
      #2

      can you post your form code?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups