dsfdsfdsfdsf1223 2014-10-30 18:52
浏览 11

我的div一直在其父母之外回应

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>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?