RE: [PHP] arrays and sessions
| From: | Chris W. Parker | Date: | Fri, 27 Feb 2004 22:37:55 +0000 |
| Subject: | RE: [PHP] arrays and sessions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-179037@lists.php.net to get a copy of this message | ||
Kermit Short <mailto:k_short@lanl.gov>
on Friday, February 27, 2004 2:10 PM said:
> I've got some code and it simply isn't working. I thought it might be
> because each time the form submits data, the array I'm storing
> information in is being re-initialized. If this is the case, I don't
> have the multidimensional array I'm trying to get, but just a vector
> array with the most recent submission data.
here are some thoughts...
sounds like you're just not keeping track of each iteration. i mean,
within the session variable you need to somehow differentiate between
each subsequent form submittal.
<?php
$iteration = ++$_POST['iteration'];
$_SESSION['post_data'][$iteration] = $_POST;
// include $iteration in the post data
// so that next time it comes around
// it can be incremented.
echo <<<QQQ
<form method="post" action="myself">
...
<input type="hidden" name="iteration" value="$iteration" />
...
</form>
?>
you should then see a multi-dimensional array with
'print_r($_SESSION);'.
this code is untested and not very complete. ;) but maybe it will give
you some ideas?
hth,
chris.