Page 1 of 1

Sending two dynamic arrays via post data, then reading

Posted: Wed Nov 23, 2005 12:09 am
by robster
Hi all, I have two arrays, one array contains dates and the other matching array contains info for each date.

ie:

Code: Select all

$date_range_array (contains X dates)
$client_info_array (contains info on each client for each of the dates in $date_range_array)
What I have is a dynamic image (graph) that is being created (using JPGraph + GD) and the only way I can display the image is to call an external php file via the <img> tag. (If I use a function or do it inline it just bails due to headers already sent error).

Based on that I have to get the two arrays sent to the php file via post (or get) data.

Given that the two arrays can change their length dependant on a user form input, how can I send the data to the php file via the post data, then once I've done that, how can I get the data from the post data (remembering it could be any length) to use it?

Pretty tricky.

Any help appreciated,

Rob

Posted: Wed Nov 23, 2005 4:43 am
by Jenk
Store the arrays in the session data, or if you must use post data, then echo the arrays into a hidden text field like so:

Code: Select all

<?php

echo "<input type=\"hidden\" name=\"myarraydata\" value=\"" . serialize($myArray) . "\" />";

?>
Then on the action page:

Code: Select all

<?php

$myArray = unserialize($_POST['myarraydata']);

?>

HTH :)