I want to get the all the indexes from a mysql table which correspond to a given student number and week number.
I use this to display the correct answers and the student’s answers side by side.
Often a student will send more than 1 time, which isn’t a problem for me.
if(isset($_POST['weeknr'])) {
$indexsql = 'SELECT id FROM allstudentsAnswers' . $class . ' WHERE studentnr = \'' . $studentnr . '\' AND weeknr = \'' . $weeknr . '\'';
$indexresult = $pdo->query($indexsql);
foreach ($indexresult as $row){
$indices[] = $row;
}
echo 'this student this week has these entries <br><br>';
print_r($indices);
On my home computer, this works fine.
print_r($indices); shows me the correct values.
I make php print_r() and echo print all info. When everything works, I will block the printing:
this student this week has these entries (print_r())
Array ( [0] => Array ( [id] => 1 [0] => 1 ) [1] => Array ( [id] => 3 [0] => 3 ) )
this student this week has these entries
there are 2 entries for this week and student number
$indices[0][0] = 1
$indices[1][0] = 3
But when I do this on my webpage, I tried all kinds of things, I get (I made 4 entries for 1 student number and week number):
this student this week has these entries (print_r())
Array ( [0] => Array ( [id] => 2 ) [1] => Array ( [id] => 3 ) [2] => Array ( [id] => 4 ) [3] => Array ( [id] => 9 ) )
there are 4 entries for this week and student number
$indices[0][0] =
$indices[1][0] =
$indices[2][0] =
$indices[3][0] =
I’ve tried many things, but, although print_r($indices); shows the correct information, I cannot grab the values in $indices, as I can on my home computer.
I need the values to output all answers.
Any suggestions please?