|
-
Dec 22nd, 2006, 02:37 PM
#1
Thread Starter
Hyperactive Member
How to work with this array?
Because of the way I am making my form (ie. with PEAR HTML_Quickform), I am getting my checkbox/textarea contents in an array as follows:
Code:
Array ( [1] => 1 [txt1] => box1 [2] => 2 [txt2] => box2 [3] => -1 [4] => -1 [5] => -1 [6] => -1 [7] => 7 [txt7] => box7 [9] => -1 )
That looks confusing so I will explain it as best I can.
The array is made up of [checkbox][textarea] etc.
When the checkbox is not checked however it's value is set to -1. And it will obviously have no corresponding [textarea] value either.
So in the above code posted, checkbox 1 is checked, and txt1 has contents 'box1'. Hope your following...
Well this has caused me endless hassles and I haven't been able to figure out how to change the array so it is easier to work with.
What would be best is for each checkbox which is checked, I can create some sort of an array with the textarea contents as its values.
Something like:
Code:
1 = box1
2 = box2
7 = box7
No doubt many of you will be confused about the array because that's what I've got so far but as far as I know that is how the Quickform package is passing me them. (I have just used print_r on the data it passes)...
Can anyone out there give me a clue or an idea on how to get the desired output 
JUST REMEMBERED: What I will be doing with this array is putting it into my table. So '1' will be saved in an 'id' field and 'box1' into a 'comment' field. Hope that makes sense.
Maybe you guys know of a better way using the above Array???
I tried using 'foreach' but obviously I only want to cycle through the checkbox arrays and add them if they are checked etc... I know it sounds confusing
Last edited by wwwfilmfilercom; Dec 22nd, 2006 at 02:40 PM.
Reason: Remembered something
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|