How to show the data of a table in codelgniter?

1

When loading my data in my view, it does not seem like anything to me

I leave you my driver

public function ver(){
    $data = array(
        'enlaces' => $this->Usuario_model->verCita()
    );
    $this->load->view('login_view', $data);
}

my model

function verCita(){
    $query = $this->db->get('eventos');
    if ($query->num_rows()>0){
        return $query;
    }else{
        return FALSE;
    }
}

and my eyesight

<!DOCTYPE html>
<html>
<head>
   <link rel="icon" href="<?php echo base_url();?>/assets/img/uni.ico">
    <title>Calendario</title>
    <link rel="stylesheet" href="<?php echo base_url();?>assets/css/fullcalendar.css" />
    <script src="<?php echo base_url();?>assets/js/jquery.min.js"></script>
    <script src="<?php echo base_url();?>assets/js/moment.min.js"></script>
    <script src="<?php echo base_url();?>assets/js/fullcalendar.js"></script>
    <style>
        .Formato{
            background: green;
            color:#ffffff;
            border-radius: 20px; 
        }
            .Formato2{
            background: red;
            color:#ffffff;
            border-radius: 20px; 
        }
    </style>

    <script language="JavaScript">
        $(document).ready(function() {

         $('#calendario').fullCalendar({
            events:[
                  <?php
                     foreach($enlaces->result() as $fila ) {
                  ?>
                     {  

                        id:"<?php echo $fila["title"];?>",
                        title:"<?php echo $fila["title"];?>",
                        start:"<?php echo $fila["start"];?>",
                        end:"<?php echo $fila["end"];?>",
                        url:"<?php echo $fila["url"];?>",
                        className:"<?php echo $fila["className"];?>",
                        editable:"<?php echo $fila["editable"];?>"

                     },
            <?php
               }
            ?>
        ]               
        })
    });  
    </script>
</head>
<body>
    <div>
        <h1> <center> Calendario de sala de juntas </center> </h1>
    </div>
    <div id="calendario"></div>

</body>
</html>
    
asked by Fernando Martinez 05.02.2018 в 19:49
source

1 answer

0

The driver you use;

public function ver(){
    $data = array(
        'enlaces' => $this->Usuario_model->verCita()
    );
    $this->load->view('login_view', $data);
}

Collect the data of the vercita () function and what it collects is displayed on the $ data variable, so in the view you should go through this array through the array $ data .

That is, you would have to use the variable in the view so it looks like this;

public function ver(){
    $data = array(
        'enlaces' => $this->Usuario_model->verCita()
    );
    **$this->load->view('login_view', $data);**
}

If you still do not find any data, check that the function of the model correctly collects the data you want to show.

I hope this helps you a greeting.

    
answered by 14.02.2018 в 15:46