I am in the middle of everything and my heads all over the place, so forgive me if this sounds stupid.
I am producing a form which has update buttons that write new entries to a database. I thought I would make it user friendly and have the values 'stick' when the form reloads so the user won't lose what they wrote. (this is not the submit stage its just a change in the selection about half way down the form)
Anyway I used $_SESSION[''] variables to record the form variables which works great for all of the boxes apart from 1. I had a bit of a headache with a multi-selection box (the one where the user can hold control button and select many). I have sorted this for writing it to the mysql database with the use of
foreach ($_POST['mulitselection'] as $value)
{
write database with individual $value;
}
The thing I need to do now is to have the array copied into
$_SESSION['multiselection'] and be able to use it the same way...
forech ($_SESSION['multiselection'] as $value)...ect
The problem stems from the fact that I cant seem to get my head around why things are not working.
$count = 0;
foreach ($_POST['multiselection'] as $value)
{
$_SESSION['multiselection[$count]'] = $value;
$count++;
foreach ($_SESSION['multiselection[]'] as $testin)
{
echo $testin ."<br>";
}
}
seems to confirm with the echo that the values are there but if I put this second foreach on the outside the values are not there. ie..
$count = 0;
foreach ($_POST['multiselection'] as $value)
{
$_SESSION['multiselection[$count]'] = $value;
$count++;
}
foreach ($_SESSION['multiselection[]'] as $testin)
{
echo $testin ."<br>";
}
So my question is how to make the $_SESSION['multiselection'] array global and why is this not and the other $_SESSION[''] variables are!??
Aghhh!
