SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru coiL's Avatar
    Join Date
    Sep 2001
    Location
    QLD, Australia
    Posts
    666
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question help with multiple checkboxes

    Hi,

    I have a script which allows people to bid for items. What I wanted to do was write a script that displays a list of what items are currently being bid on - and under each item, a list of people who have bid for each item.

    From that page I wanted the admin to select the winning bid for each item, submit the selection which would then print a page of the items and just the winning bids.

    I was going to use checkboxes to allow the admin to select the winners, but am not sure how to go about using them. I would need to pass on the item id and the member id through the form. [img]images/smilies/xeye.gif[/img]

    I'm not sure that this is what I need to do, but this is what I have at the moment:
    PHP Code:
     <?

    <td><input type="checkbox" name="<?php echo $item_id."[]" ?>" value="<?php echo $member_id ?>"></td>

    ?>
    after that I'm not really sure how I get the results to print on the next page.

    There may be up to 25+ items listed on the page - with up to 10 bids for each item.

    any help/info/advice would be greatly appreciated.

    thanks [img]images/smilies/smile.gif[/img]
    coiL
    "cradled in the learning curve"

  2. #2
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    466
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    checkboxes cannot pass values - they only pass 'on' oir 'off'

    you could use a comma seperated array as the name

    <input type="checkbox" name="winner['<?= $item_id.','.$member_id; ?>']"

    then
    foreach($_POST['winner'] as $test_win)
    {
    if($test_win == "on")
    {
    explode(',',$test_win);
    // $test_win[0] = the item id
    // $test_win[1] = the member id
    echo 'item #' .$test_win[0]. ' bought by member #' .$test_win[1]. '<br />';
    }
    }

    seriously untested though and might need a bit of tinkering.
    teckis - that's news to me.

  3. #3
    SitePoint Zealot Sork's Avatar
    Join Date
    Jul 2002
    Location
    Portugal
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pootergeist
    checkboxes cannot pass values - they only pass 'on' oir 'off'
    Checkboxes can pass values

  4. #4
    SitePoint Guru coiL's Avatar
    Join Date
    Sep 2001
    Location
    QLD, Australia
    Posts
    666
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Sork
    Checkboxes can pass values [img]images/smilies/wink.gif[/img]
    yup, I'm having a go with
    PHP Code:
      <td><input type="checkbox" name="winner[]" value="<?= $item_id.$mem_id?>"> </td>
    will see how I go with it.
    coiL
    "cradled in the learning curve"


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
  •