Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: break up array

  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    156
    Thanks
    8
    Thanked 1 Time in 1 Post

    break up array

    can someone send me to a tutorial that helps me breakup _POST results.

    I'm using a table that shows all information from a DB. The client wants a checkbox next to each that allows you to select a few then print them. I'm sending the ID number as the value for "Selected" to the action page, so I need to split each post up to grab again from the DB and print results out.

    thanks in advance,
    ziggy

  • #2
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    866
    Thanks
    7
    Thanked 30 Times in 29 Posts
    here is a tutorial on posted data..
    http://www.w3schools.com/php/php_post.asp

    and here is a tutorial on how to split strings into arrays.
    http://www.phpdig.net/ref/rn53re1094.html

    You should also look at the PHP manual for other methods...such as explode, impolde etc.

    http://www.php.net/split

  • #3
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    So your form fields are an array of checkboxes?
    eg. they have a fieldname like "mycheckboxes[]"?
    If so you can loop through them like any other array

    eg.

    PHP Code:
    foreach($_POST['mycheckboxes']) as $id)
    {
    //grab from db


  • #4
    Regular Coder
    Join Date
    Mar 2005
    Posts
    156
    Thanks
    8
    Thanked 1 Time in 1 Post
    Quote Originally Posted by NancyJ View Post
    So your form fields are an array of checkboxes?
    eg. they have a fieldname like "mycheckboxes[]"?
    If so you can loop through them like any other array

    eg.

    PHP Code:
    foreach($_POST['mycheckboxes']) as $id)
    {
    //grab from db


    Thats not exactly how I was going to do it, but it looks easier. So my fieldname would be "mycheckboxes[2222]" and "mycheckboxes[1111]"? Am I seeing this right?

    thanks

  • #5
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    your fieldnames would be mycheckboxes[] and the id number would be in the value (unless there is some other info you need/want to put in the value)

  • #6
    Regular Coder
    Join Date
    Mar 2005
    Posts
    156
    Thanks
    8
    Thanked 1 Time in 1 Post
    Quote Originally Posted by NancyJ View Post
    your fieldnames would be mycheckboxes[] and the id number would be in the value (unless there is some other info you need/want to put in the value)
    yeah, i've been playing with it... Thanks a ton!

    ziggy


  •  

    Posting Permissions

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