...

View Full Version : break up array



ziggy1621
07-16-2007, 05:23 PM
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

ess
07-16-2007, 06:20 PM
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

NancyJ
07-16-2007, 06:58 PM
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.



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

ziggy1621
07-16-2007, 09:23 PM
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.



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

NancyJ
07-16-2007, 09:29 PM
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)

ziggy1621
07-16-2007, 09:37 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum