SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    so far so good. Again, I have a problem:

    I have a list of items all with a checkbox placed before (in HTML). This list is generated with PHP so a checkbox always goes like this:
    Code:
    <input type=checkbox name=id value=\"" . $id . "\">
    I want to parse this 'array' of id's and change all the values in a mySQL table of those which have a checked checkbox...

    I'm sure someone knows the solutions, so please help.
    Thanks alot!

  2. #2
    SitePoint Zealot oodie's Avatar
    Join Date
    Jul 2000
    Location
    Misty Mountain
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want to parse this 'array' of id's
    If you want an array, then you have to change the 'name' attribute to 'id[]' instead of 'id'. When this form is submitted, you will have an array variable $id which contains the value of checkboxes that are checked. If the name is 'id', then you will have a variable which only contains the value of the last checked checkbox. Change it like this :

    Code:
    echo "<input type=checkbox name=\"id[]\" value=\"". $id . "\">";
    After you submit the form, you can access these values using loop :

    Code:
    for($i=0; $i<count($id); $i++) {
    // do something with $id[$i]
    }

  3. #3
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!!!
    Oh, great!


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
  •