[eluser]Unknown[/eluser]
Please I need help with this code
This is the error that occurs when running
ERROR
Fatal error: Call to a member function result() on a non-object in C:\wamp\www\mobilestore\application\views\cliente.php on line 4
CONTROLLER
class ClienteController extends CI_Controller {
public function index() {
}
public function search($id) {
// echo ('estamos aqui');
$this->load->model('Cliente_Model');
$data['contenido'] = $this->Cliente_Model->search1($id);
$data['title'] = 'Relacion de Clientes';
$data['main_content'] = 'cliente';
$this->load->view('includes/template_general', $data);
}
}
MODEL
class Cliente_Model extends CI_Model{
//Public var $id1 = "";
function __construct(){
// Call the Model constructor
parent::__construct();
}
Public function search1($id){
echo ($id);
$this->db->select('intClienteId , varRazonSocial, varLogoCliente, varDireccion, varTelefono1Cliente, varCorreo1Cliente, varURL1Cliente');
$this->db->where('varTipo1ClienteId',$id);
$query = $this->db->get('tb_cliente');
if ($query -> num_rows>0){
return $query->result();
}else {
return FALSE;
}
}
}
VIEWS
1
2 <ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b" data-filter="true">
3 <li data-role="list-divider" data-corners="true" data-inline="true" ><?php echo $title?></li>
4 <?php foreach ($contenido->result() as $item):?>
5 <li data-ic><?php echo anchor('clientecontroller/search/?id='.$item->intClienteId.'',$item->varRazonSocial);?><span class="ui-li-count">0</span></li>
6 <?php endforeach;?>
7 </ul>