Pages: [1]   Go Down
Author Topic: 3D Array's from a form  (Read 66 times)
TomSayer
Jr. Member
**

Karma: +0/-0
Offline Offline

Posts: 14


« on: March 07, 2010, 09:46:24 PM »

I've had  quick search through the forums, and couldn't find anything related to this!
What i'm trying to do is take 3D array data from a form of variable length (depending upon how many dba entries are called).
The form is to allow me to quickly edit around 40 odd users with varying pieces of data for each.
When the form is generated, each user has 5 pieces check boxes associated to it in the array, as below.
Code:
<input type='checkbox' name='pass[29][mon]' value='1'>
the first [] being the individual user, the second the relevant data.
The form is being generated as it should be, however when its posted to be processed, none of the information is being recieved. It could be that i'm trying to call it wrong ($_POST['pass[$i][mon]'], $i being the users ID generated whilst looping through)? I've not had to deal with 3d arrays before, or arrays from forms, so i could be doing this entirely wrong!

Hopefully i've been clear enough in this! If not, ask for more!

~Tom
Report to moderator   Logged

hotnoob
PhpBar.isgreat.org
Hero Member
*****

Karma: +0/-0
Offline Offline

Posts: 113


WWW
« Reply #1 on: March 10, 2010, 03:21:07 AM »

if you are going to put a variable in a name it should be with " " instead of ' '
Single quotes are for static strings
double quotes are for dynamic strings.

So to solve your problem... if you are using a loop of some sort... i can only assume...
Code:
<?php
  
//ill make a loop if u havnt anyway...
  //you can use isset if you want, but i like empty() better
  
$i 0// set it to 1, if u started with 1.
  
while(!empty($_POST['pass['.$i.'][mon]']))
  {
     echo 
$_POST['pass['.$i.'][mon]'];
     
//or
     
echo $_POST["pass[$i][mon]"];
     
$i++;
  ]
?>



i also don't like for loops Tongue
Report to moderator   Logged

http://phpbar.isgreat.org
Feel free to check out my forums for more tutorials and help Cheesy

TomSayer
Jr. Member
**

Karma: +0/-0
Offline Offline

Posts: 14


« Reply #2 on: March 10, 2010, 03:33:32 AM »

I hate them too Tongue Nothing wrong with while!
& thanks for the help, i had a good google looking for references, but never found it!

I'll plug that in and see how we're doing after the football!
Report to moderator   Logged

Pages: [1]   Go Up
Print
 
Jump to:  

Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC | Theme Kani By Fussilet

Page created in 0.036 seconds with 21 queries.