EDIT : Does not work on external hosting AND on localhost… So I must be doing something wrong.
I am working with Code Igniter and I have a view. My view page shows no error, but doesn't show the data I requested either. Everythings fine with my config and database I guess... Any idea ? Am I doing anything wrong here? I am using latest version of mamp on mac 4.4.1 and latest version of code igniter 3.1.7.
Thanks guys in advance for your help ;)
View
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html lang="en">
<head>
<body>
<div>
<p> <?php
echo 'Trying to display:' . $data . ' yes?';
?> </p>
</div>
</body>
</html>
Model
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome_model extends CI_Model {
function __construct()
{
parent::__construct();
}
function get_secret($id)
{
$this->db->where('id', $id);
$this->db->select('secret');
$query = $this->db->get('tch_api');
if ($query->num_rows==1) {
foreach ($query->result() as $row) {
// tried with this line too : $secret = $row->secret; and without the following one same result
$data[] = $row->secret;
}
return $data;
}
}
}
Controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
$this->load->model('welcome_model');
$secret = $this->welcome_model->get_secret(1);
$data = array(
'data' => $secret
);
$this->load->view('welcome_message', $data);
}
}