PHP Session / Array Problem accesing

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-05-18T16:17:49Z Indexed on 2010/05/18 16:20 UTC
Read the original article Hit count: 188

Filed under:
|

Hello,

I have a form that certain data, which then gets calculated and gets displayed in a table.
All the data gets saved in a 2 dimensional array.
Every time i go back to the form the new data gets saved in the array. That data will be displayed in the next table row and so on.

I have used print_r($_Session) and everything gets properly saved in the array.

Although i have no idea how to acces the session variables area, floor, phone, network etc wich are now in the array.

Without arrays i stored them in a variable for example $phone , and did calculations with it. But now when i use the arrays, i keep on getting undefined index phone etc...

How can i acces these variables, been looking at this for hours without getting any closer to a solution.

Any help much appreciated. Regards.

First page:

if (empty ($ _POST)) 
( 
    Mode = $ name $ _POST ['state name']; 
    $ Area = $ _POST ['size']; 
    $ Floor = isset ($ _POST ['floor'])? $ _POST ['Floor'] 0, / / if checkbox checked value 1 else 0 
    $ Phone = isset ($ _POST ['phone'])? $ _POST ['Phone']: 0; 
    $ Network = isset ($ _POST ['network'])? $ _POST ['Network']: 0; 

    / / Control surface 
    if (is_numeric ($ area)) / / OK 
    ( 
        if (isset ($ _SESSION ['table'])) 
        ( 
            / / Create a new row to the existing session table 
            $ Table = $ _SESSION ['table']; 
            $ Number = count ($ table); 
            $ Table [$ count] [0] = $ file name; 
            $ Table [$ count] [1] = $ size; 
            $ Table [$ count] [2] = $ floor; 
            $ Table [$ count] [3] = $ phone; 
            $ Table [$ count] [4] = $ network; 
            $ _SESSION ['Table'] = $ table; 
        ) 

        else 
        ( 
            / / Create the session table 
            $ Table [0] [0] = $ file name; 
            $ Table [0] [1] = $ size; 
            $ Table [0] [2] = $ floor; 
            $ Table [0] [3] = $ phone; 
            $ Table [0], [4] $ = network; 
            $ _SESSION ['Table'] = $ table; 
        ) 

            header ("Location: ExpoOverzicht.php"); 

    ) 
            else 
            ( 
                echo "<h1> surface Wrong - New try </ h1>"; 
            ) 

)

When i made the php code withotu the arrays i declared like this, and it worked fine. But now there in the array, and i have no idea how to "acces them"

$standnaam = $_SESSION["standnaam"];
$oppervlakte = $_SESSION["oppervlakte"];
$verdieping = $_SESSION["verdieping"];
$telefoon = $_SESSION["telefoon"];
$netwerk = $_SESSION["netwerk"];

© Stack Overflow or respective owner

Related posts about php

Related posts about beginner