views:

119

answers:

2

I have been trying to figure this out for awhile. I have a multidimensional array in JavaScript that is 12 columns wide and an unknown number of rows like so

/*
[
    [userID (int), name, username, email, password, other 1, other 2, other 3, other 4, other 5, other 6, admin(int)],
    [userID (int), name, username, email, password, other 1, other 2, other 3, other 4, other 5, other 6, admin(int)],
    [userID (int), name, username, email, password, other 1, other 2, other 3, other 4, other 5, other 6, admin(int)],
    ...
]
*/

All the values are string except the (int) ones. This is for a real time user editing page for my site. I have the JavaScript array made now I need it so when the "Submit" button is pressed it turns the array formated like that into an PHP array and saves it as a variable. Can I get some help?

+3  A: 

Encode to JSON, post to PHP via Ajax or regular Form and decode on the serverside with json_decode

Gordon
I do not know them. :(
@user275241 them what?
Gordon
Nevermind, I am looking at the JSON thing...
That was the most odd comment I've seen on SO
dscher
A: 

What you need to do is add the data to hidden fields in your form, if they are not already regular input fields.

You probably want to use field naming like this:

<input type="hidden" name="data[100][username]" value="myusername" />
<input type="hidden" name="data[100][email]" value="[email protected]" />

Where 100 is whatever each user id is.

DisgruntledGoat
It has a new user function and can be edited live. I do not see how that would work with that.
now if you can set value to innertext that would work =/