I have this div, which runs some php and then passes one of three sets of parameters to a function. The function returns an echoed div. For some reason, this div is appearing below the parent instead of inside it. It seems pretty straightforward, which is why it's causing me so much trouble. What am I missing?
This is the parent div:
<div class='panel-body' hrid='<?php echo $homeroom['homeroom_id'] ?>'>
<!-- figure out $class, $lunchroom, and $order for each div containing student -->
<?php
$students = get('student', ['homeroom_id' => $homeroom['homeroom_id']], 'student_id', '', 'API')->fetchAll();
foreach($students as $student){
$class='';
$dest = '';
if(in_array($student['student_id'], $detentionIds)){
echo returnStudent('detention', $firstRoundDetention, $homeroom, $notUsed, $student, 1);
}elseif(in_array($student['student_id'], $hwIds)){
echo returnStudent('homework-club', $firstRoundHC, $homeroom, $notUsed, $student, 2);
}else{
echo returnStudent('recess', $firstRoundRecess, $homeroom, $notUsed, $student, 3);
}
} ?>
</div>
And this is the function that generates the div to be echoed inside the parent:
function returnStudent($class, $array, $homeroom, $notUsed, $student, $dataSort){
if($homeroom['homeroom_id'] == $array['room1']){
$class.= ' not-moved';
$dest = $array['room1'];
$suffix = 'homeroom matches room1';
}else{
if(in_array($homeroom['homeroom_id'], $array['rooms'])){
$class.= ' moved';
$dest = $array['room1'];
$hr = get('homeroom', ['homeroom_id' => $array['room1']], 'homeroom_id', 1, 'API')->fetch();
$suffix = $hr['homeroom_name'];
}else{
if($notUsed['homeroom_id'] == $homeroom['homeroom_id']){
$class.= ' not-moved';
$dest = $homeroom['homeroom_id'];
$suffix = 'does not move';
}else{
$class.= ' moved';
$dest = $notUsed['homeroom_id'];
$hr = get('homeroom', ['homeroom_id' => $notUsed['homeroom_id']], 'homeroom_id', 1, 'API')->fetch();
$suffix = $hr['homeroom_name'];
}
}
}
return "<div
class='alert student " . $class ."'
destination = '" . strtolower($dest) ."'
data-sort = '" . $dataSort . "'
studentid='" . $student['student_id'] ."'
homeroomid = '" . $student['homeroom_id'] . "'>
" . $student['student_fname'] . " " . $student['student_lname'] . " - " . $suffix ."
<!-- close student div -->
</div>";
}
</div>