Select in codeigniter produces Name? instead of a list of names

0

I use codeigniter and php, I make a select and in the view instead of leaving a set of records in the Name field, it comes out: Name? >

form_search_client.php

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
        <TITLE></TITLE>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0">         
        <!-- <link rel="stylesheet" type="text/css" href="<?php /*echo base_url();*/ ?>/css/estilos.css"> 
         <link rel="stylesheet" type="text/css" href="http://localhost/CesdeCodeIgniter/application/views/css/estilos.css"> -->
        <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>/css/bootstrap.min.css"> 

        <style type="text/css">
            body{
                margin:0;   
                color:#6a6f8c;  
                font:600 16px/18px 'Open Sans',sans-serif;
            }

            html {
                height: 100%;
            }
        </style>    
</head>

<body>
    <br>
        <div class="container-fluid">
            <br>
            <div class="row">
                <div class="col-md-10">
                    <ul class="nav nav-pills">
                        <li role="presentation" ><a href="http://localhost/CesdeCodeIgniter/index.php/cliente/mostrarInicio">Inicio</a></li>
                        <li role="presentation" class="active"><a href="http://localhost/CesdeCodeIgniter/index.php/cliente/mostrarDatos/cliente">Ingresar Cliente </a></li>
                        <li role="presentation" ><a href="http://localhost/CesdeCodeIgniter/index.php/cliente/buscarCliente">Buscar Cliente </a></li>
                        <li role="presentation"><a href="cuentaxcliente.php">Cuenta Cliente</a></li>
                        <li role="presentation"><a href="transaccuenta.php">Transación Cuenta</a></li>
                        <li role="presentation"><a href="http://localhost/CesdeCodeIgniter/index.php/transaccion/IngresarTransaccion">Ingresar Tipo de Transacción</a></li>
                        <li role="presentation"><a href="http://localhost/CesdeCodeIgniter/index.php/transaccion/BuscarTransaccion">Buscar Tipo de Transacción</a></li>
                        <li role="presentation"><a href="http://localhost/CesdeCodeIgniter/index.php/cliente/login">Login</a></li>

                    </ul>
                </div>
            </div>
        </div>

    <br><br>    



    <?php
        foreach ($clientes->result() as $c) { ?>
            <ul>
                <li><?php= $c->Nombre ?></li>
            </ul>

        <?php } ?>  
    <br>    


    <script type="text/javascript" src="http://localhost/CesdeCodeIgniter/js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="http://localhost/CesdeCodeIgniter/js/bootstrap.min.js"></script>            

</body>
</html>

main_model

<?php  
 class Main_model extends CI_Model  
 {  
    public function __construct() {
        //llamamos al constructor de la clase padre
        parent::__construct();

        //cargamos la base de datos
        $this->load->database();
    }       

    public function insertar($datos){
      $this->db->insert('tbl_cliente', array('DocIdent'=>$datos['documentoDeIdentidad'], 
        'Nombre'=>$datos['nombre'],
        'Apellido'=>$datos['apellido'],
        'Direccion'=>$datos['direccion'],
        'Telefono'=>$datos['telefono'],
        'Estado'=>$datos['estado'],
        'FechaIngreso'=>$datos['fechaIngreso'],
        'Password'=>$datos['password']
      ));
     }

     public function obtenerClientes(){
        $query = $this->db->get('tbl_cliente');

         if($query->num_rows()>0){            
            return $query;            
        }else{
            return false;
        } 
     }

client_search (the driver)

<?php
 defined('BASEPATH') OR exit('No direct script access allowed');

    class cliente_buscar extends CI_Controller{
        function __construct(){
            parent::__construct();
            $this->load->helper(array('form', 'url'));
            $this->load->library('form_validation');
            $this->load->database();
            //llamo o incluyo el modelo
            $this->load->model('main_model');

        }

        function listado(){
            $data['clientes'] = $this->main_model->obtenerClientes();
            $this->load->view('formulario_buscar_cliente', $data);
        }
    
asked by Jhon Hernández 06.10.2018 в 07:56
source

2 answers

0

Have you considered changing the syntax of?

<?php= $c->Nombre ?>

a

<?php echo $c->Nombre; ?>
    
answered by 06.10.2018 в 09:13
0

Name? > it's likely that short open tags you have disabled

Enter the php.ini search for the line

short_open_tag and set it to ON, and restart the server.

enabled the short_open_tag write it as follows:

introducir el código aquí

If it does not solve you, write the complete one like this:

<?php echo $c->Nombre; ?> //sin olvidar el punto y coma.

this is valid with the short_open_tag enabled or not.

I hope I have helped you.

    
answered by 08.10.2018 в 01:42