Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How best to pass on a 2d array grid of variables =/

Status
Not open for further replies.

Leozack

MIS
Oct 25, 2002
867
GB
I've got a table on-screen build up of a 2d array
($array[$i][$n])
and basically I have that and some other things that need to be picked up by the script everytime it is loaded. ATM, instead of submitting the form to the page every time I'm using a button with an onclick set to goto the page again with appropriate &this=$that on the end of the url. This works fine for passing on 1 or 2 variables.
However, with this huge grid of upto 10x30 entries I don't see how I can get each entry onto the end of the url in any form.
Basically I see my options as somehow managing to get hold of the 2d array via $http_post_vars or something, using cookies to store the 2d array somehow, or using sessions to store the 2d array somehow.
I really am puzzled and I'd appreciate the voice of experience on these things =)
 
For the amount of data you are sending, I strongly recommend storing that information in a session variable. Transmitting that data back and forth through hidden fields and the POST method is clunky, and sooner or later you're going to run into the maximum length for a URL using GET method.

Assuming you are running a recent version of PHP, session management is not difficult.

At the point where this info needs to be stored, that script must issue session_start() at the beginning of the script, then register the array with the function session_register (&quot;<name of variable>&quot;);

At the beginning of each script which needs access to the data, invoke the function session_start(). PHP will make the 2d array available to you in the associative array $_SESSION (if running PHP v. >= 4.1.0) or $HTTP_SESSION_VARS (all recent versions). session_register() only needs to be invoked once.

______________________________________________________________________
Did you know?
The quality of our answers is directly proportional to the number of stars you vote?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top