Re: Array in a $_session
| From: | Frank Keessen | Date: | Mon, 16 Jun 2003 21:43:03 +0000 |
| Subject: | Re: Array in a $_session | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-151739@lists.php.net to get a copy of this message | ||
John,
Thanks but nothing is displayed on page 3.... Any thoughts???
(page 2)
$_REQUEST["submit"]=isset($_REQUEST["submit"])?$_REQUEST["submit"]:"";
if($_REQUEST['submit']!="")
{
foreach($_POST['test1'] as $i => $Value) {
$_SESSION['test1'][$i] = $_POST['test1'][$i];
}
header("Location: step3.php");
}
(page 3)
session_start();
$test1 = $_SESSION['test1'][$i];
echo $test1;
for ($i=1; $i<=$_SESSION['test1'][$i]; $i++)
{
echo $test1;
}
Thanks for your time!
Frank
----- Original Message -----
From: "John W. Holmes" <holmes072000@charter.net>
To: "Frank Keessen" <fkeessen@planet.nl>
Cc: <php-general@lists.php.net>
Sent: Monday, June 16, 2003 11:34 PM
Subject: Re: [PHP] Array in a $_session
> Frank Keessen wrote:
> > Still strugling with array's ;> : Can you help me with this??
> >
> > <input type=\"text\" name=\"test1[$i]\" size=\"6\">
> >
> > How can i put that value into an $_SESSION??
> >
> > Something like $_SESSION["test1"][$i]??
> >
> > This is the way i put into a database
> >
> > foreach($_POST['test1'] as $i => $Value) {
> > $query = "INSERT INTO test (test1, test2, test3, test4 , test5) VALUES
('".$_POST['test1'][$i]."',
'".$_POST['test2'][$i]."',
'".$_POST['test3'][$i]."',
'".$_POST['test4'][$i]."',
'".$_POST['test5'][$i]."')";
> > $result = mysql_query($query);
> >
> >
> > But i've got no clue how to put into a session and retrieve it..
>
> $_SESSION['test1'][$i] = $_POST['test1'][$i]
>
> Assuming you're setting $i to something in the processing script...
>
> --
> ---John Holmes...
>
> Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
>
> PHP|Architect: A magazine for PHP Professionals – www.phparch.com
>
>
>
>