我无法从数据库、代码点火器中选择我的用户级别


I can't select my users level from the DB, codeigniter

im试图从我的数据库中获取用户的级别,并在视图中打印它们,但我做不到。

控制器:

public function add_notificacion() {
    $data = array();
    if (!empty($this->input->post('mensaje', TRUE))) {
        if (($this->input->post('id_profesor', TRUE) != 0)) {
            $id_profesor = $this->input->post('id_profesor', TRUE);
            $this->load->model('Profesor_model', 'profesor');
            $json_data = $this->profesor->gets_profesor($id_profesor);
            foreach ($json_data as $fila) {
                $nivel[] = $fila->id_nivel;
            }
        } else {
            $nivel = $this->input->post('niveles', TRUE);
        }

视图:

div class="col-md-5 col-sm-5 col-xs-5">
                    <label for="niveles">Niveles</label>
                </div>
                <div class="col-md-14 col-sm-25 col-xs-25">
                    <?php if ($temp == 0) { ?>
                        <input id="todo" name="todo" type="checkbox"> Todos <br>
                    <?php } ?>
                    <?php
                    if(!empty($nivel)){
                    foreach ($nivel as $fila) {
                        if (in_array($fila->id_nivel, $id_nivel[0])) {
                            ?>
                            <input disabled="disabled" id="nivel" class="che" name="niveles[]" type="checkbox" value="<?= $fila->id_nivel ?>" checked="" onclick="checkAddress(this)" style="cursor:auto;"> <?= $fila->nombre . " " . $fila->seccion ?><br>
                            <div id="repre"> </div>
                            <?php
                        } else {
                            ?>

型:

function gets_profesor($id_profesor) {
    $result = $this->db->get_where('profesor', array('id_profesor =' => "$id_profesor"));
    return $result->result();
}

表单只向我显示"待办事项"复选框,但我需要打印每个"Nivel"用户。

对不起

,我的新手代码,但这可能会有所帮助。

假设您有一个名为"users"的表和一个名为"level"的字段和另一个名为"用户名"的字段。

$getlevels = mysqli_query($con,"SELECT * FROM users");
while($r = mysqli_fetch_array($getlevels)){
$username = $r['username'];
$level = $r['level'];
echo $username," - ",$level,"<br>";
}

之后将显示每个用户及其级别