Retrieve data from a <table>

Discussion in 'PHP' started by StorM_GmA, Jul 3, 2008.

  1. #1
    Hello!

    I'm developing a website for an university assignment. The website is an online shop and i'm currently design the shopping cart with PHP. When the user view the shopping cart, the website is generating a table with 4 colums and as many rows as the items he has in his shopping cart.

    The problem now is that in 1 column I have an <INPUT TYPE=text> for the quantity of the products. How can I detect which INPUT TYPE the user has changed in order to update the database? I thought that I could add an ID column but I don't know what can I read data from the table...

    Thanks alot!
     
    StorM_GmA, Jul 3, 2008 IP
  2. Greg Carnegie

    Greg Carnegie Peon

    Messages:
    385
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you name each of the inputs like:
    <input type="text" name="quantity[]">

    Then after sending form by POST you can loop thru all quantity fields:
    
    foreach($_POST['quantity'] as $item_$quantity)
    {
        // do something
    }
    
    PHP:
    Hope that helps.
     
    Greg Carnegie, Jul 3, 2008 IP