I looked around before PHP - How to send an array to another page?, but my situation is different.
I have this program on a page, this is the query block:
while ($row = sqlsrv_fetch_array($query))
{
$questions[] = "$row[Question]";
$optionA[] = "$row[OptionA]";
$optionB[] = "$row[OptionB]";
$optionC[] = "$row[OptionC]";
$optionD[] = "$row[OptionD]";
}
Then I do something like this to echo questions on screen
$lengthquestion = count($questions);
$_SESSION['length'] = $lengthquestion;
for($i = 0; $i < $lengthquestion; $i++)
{
echo $questions[$i];
}
Now I want to be able to access this questions array in a different php file. But where I get confused/stuck with what I have been trying is that I would still need to access each element of the array on the next page. How do I go about it?
So far I have been playing with sessions, but then I get array to string conversion error.
Second php page:
$UpperLimit = $_SESSION['length'];
for($i = 0; $i < $UpperLimit; $i++)
{
}