I had a stupid parse error… finally got it.
:)
thanks for your help!
B
On Feb 23, 2018, at 2:40 PM, Chris Hansen <chris@xxxxxxxxxxx> wrote:
Hey Bob,
Does anything come out of the session array at all? If not, the session may
not yet be started... Do you call session_start() before doing anything else
with the session? Also, have you declared the 'student_array' element to be
an array, like so:
$_SESSION['student_array'] = array();
Once you do that, option one in your question should work just fine...
HTH
--Chris
On 2/23/18 1:37 PM, Bob Patin wrote:
OK, absolutely last question:
I’m storing the array in a session variable; I tried this:
$_SESSION['student_array'][] = array(…
and I tried this:
$_SESSION[‘student_array[]'] = array(…
but neither of those are correct; how do I add rows to an array stored in a
session var?
B
On Feb 23, 2018, at 2:33 PM, Chris Hansen <chris@xxxxxxxxxxx
<mailto:chris@xxxxxxxxxxx>> wrote:
Yeah, you need an "as" clause in that foreach:
foreach($_SESSION['student_array'] as $student){
print_r ($student);
}
Howzzat?
On 2/23/18 1:30 PM, Bob Patin wrote:
I figured a foreach loop would be the way, but this doesn’t run:
foreach($_SESSION['student_array']){
print_r ($_SESSION['student_array']);
}
Missing something obvious, no doubt… ?
On Feb 23, 2018, at 2:24 PM, Bob Patin <bob@xxxxxxxxx
<mailto:bob@xxxxxxxxx>> wrote:
I was thinking I was going to initialize the array when the site loaded,
but hadn’t thought about just using isset().
Sometimes the easiest stuff makes me over-complicate…
Now to figure out how to return subsequent rows… ?
B
On Feb 23, 2018, at 2:20 PM, Beverly Voth <beverlyvoth@xxxxxxxxx
<mailto:beverlyvoth@xxxxxxxxx>> wrote:
DITTO! isset() = my hero.
Beverly
Sent from miPhone
On Feb 23, 2018, at 3:17 PM, Chris Hansen <chris@xxxxxxxxxxx
<mailto:chris@xxxxxxxxxxx>> wrote:
I like using isset($someVariable) to check whether something exists.
Avoids all sorts of mess =)
--Chris