Welcome Guest, Not a member yet? Register   Sign In
Newbie Can't get the page load [Solved]
#1

[eluser]GabrieleMartino[/eluser]
I had to set well the routes in config file.
Hi,

i'm trying to learn php and codeigniter therefore i suppose you will find simple my problem.
I'm following the user_guide with some adaptation to what i need.
I have a db with a table user with columns like email and user_name.
I create a class

User_model with a method to get the information from the db.

After that i create a controller with a method to call the data and display them.

After i create a view that catch the variable to visualize.

I have no clear how to make them work bacause not header and footer are displayed.

I post some code for be exaustive. I omitt what i don't think is relevant.

file users_model.php in models folder:

Code:
class Users_Model extends CI_Model {

public function __construct()
{
  $this->load->database();
}
public function get_users($email = FALSE)
{
          ...
}
}

file user.php in controllers folder

Code:
class Users extends CI_Controller {

public function __construct()
{
  parent::__construct();
  $this->load->model('users_model');
}


public function view1()
{
  $data['title'] = 'User List';
  $data['users'] = $this->users_model->get_users();
  
  $this->load->view('templates/header', $data);
  $this->load->view('users/view1', $data);
  $this->load->view('templates/footer');
}
}
?>

File user/view1.php in views folder:

Code:
<?php foreach ($users as $users_item): ?>

    <h2>&lt;?php echo $users_item['user_name'] ?&gt;</h2>
    <div id="main">
        &lt;?php echo $users_item['language'] ?&gt;
    </div>
    <p><a href="users-email/&lt;?php echo $users_item['email'] ?&gt;"></a></p>
&lt;?php  echo  "letta" ?&gt;
&lt;?php endforeach ?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB