If I have an array:
$resultArr = pg_fetch_array($result,NULL);
and at the top of my php code I declare:
$_SESSION['resultArr'] = $resultArr;
Why can't I access the array elements like so:
for($i = 0; $i < $NUM_COLUMNS; $i++){
// creation of the table and row are handled elsewhere.
// The table is also within a <form> if that matters
echo "<td>" .$_SESSION['resultArr'][$i]."</td>";
}
My table ends up having empty columns and I can't figure out why...
EDIT: I figured it out. I was declaring $_SESSION['resultArr'] = $resultArr; at the top of my code (right after session_start()) and it wasn't getting set. I moved it down to the point right after $resultArr = pg_fetch_array($result,NULL);
Is this how it's supposed to work or should it have worked fine at the top of the code?
var_dump($_SESSION['resultArr']);output?$NUM_COLUMNSset to? Also, are you remembering to start the session?var_dump($_SESSION['resultArr'])to find out what's inside.$NUM_COLUMNSis your problem$_SESSION['resultsArr']is null.