I have a php file that produces a graph, populated through the answers of 4 sql statements, in another php file i have a simple loop that requests the image by posting a variable through session to a variable nested within the sql of the image file.
i have checked that the ‘sent’ variable is iterating through my loop… but the problem is that if i want to itterate by 2 the 2 images i get are of the last result instead of graph1, graph2, i get graph2, graph2…
is their something i missing? Please any help – very new to PHP thanks 🙂
heres the loop;
<?php
session_start();
for ($i = 1; $i < 3; $i++)
{
$_SESSION['question'] = $i;
?>
<div id="apDiv1"><img src="round.php"></div>
<?php
}
?>
Yes, sessions in PHP are blocking. That means while your script in question runs, the
round.phpscript does not run. It will wait until the script in question has finished.More correctly: even longer. The output must even go to the browser first.
Then it provides you the graphs as images. The
$_SESSIONvariable then is longtime to 2 already.Instead pass a query parameter (
$_GETparameter),$_SESSIONdoes not work here.