SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What property inside the form can I use to assign this index string [‘size’]

    I have this database field that used as the form input value '. $variety['price']. ' I also have a '. $variety['size']. ' database field that carry the name of the product but I don't know what another form input property to use to assign this size database field as a value to the input form property?

    I feel like I have run out of properties to carry more values to other values beside price to cart.php.

    Thank you the script is as below.

    PHP Code:
    <form action="cart.php" method="post">
    foreach(
    $product['varieties'] as $variety){ 
    echo
    '<input style="width:10px; margin-left:9px; " name="price[]" type="checkbox" value="' $variety['price']. '"  />';
    }
    </
    form

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you should name the fields in different way rather than the array price[] to something like
    price_1, size_1
    price_2, size_2,
    ......
    price_n, size_n

    And in the same way you should get them in the submitting script/page.
    PHP Code:
    $index 1;
    foreach(
    $product['varieties'] as $variety){ 
        echo 
    '<input style="width:10px; margin-left:9px; " name="price_' $index '" type="checkbox" value="' $variety['price']. '"  />';
        echo 
    '<input name="size_' $index '" type="text" value="' $variety['size']. '"  />';
        
    $index++; 

    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like you did it in the previous post.

    It passed through my mind to name it differently as well.

    I got that so instead of putting to value to the same input which I thought it was impossible since the form was going to get confused then two input per interaction one for the price and one for the size, plus name each price and differntly as you have done above.

    Thank you very much.


Bookmarks

Posting Permissions

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