Skip to content

Commit

Permalink
user profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
Shemona Singh authored and Shemona Singh committed Dec 3, 2017
1 parent f2345dc commit 6fa68d4
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
2 changes: 1 addition & 1 deletion www/application/controllers/All_Tweets.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function __Construct(){
parent::__Construct ();
$this->load->database(); // load database
$this->load->model('All_Tweets_Model'); // load model
$this->output->disable_profiler(TRUE);
$this->output->enable_profiler(TRUE);
}

public function index() {
Expand Down
19 changes: 19 additions & 0 deletions www/application/controllers/User_Tweets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Users_Tweets extends CI_Controller {

function __Construct(){
parent::__Construct ();
$this->load->library('session');
$this->load->database(); // load database
$this->load->model('Users_Tweets_Model'); // load model
$this->output->enable_profiler(TRUE);
}

public function index() {
$this->data['posts'] = $this->Users_Tweets_Model->getPosts(); // calling Post model method getPosts()
$this->load->view('user', $this->data); // load the view file , we are passing $data array to view file
}

}
18 changes: 18 additions & 0 deletions www/application/models/Users_Tweets_Model.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
class User_Tweets_Model extends CI_Model {

function getPosts(){

$_SESSION['user_id'] = $id;


$this->db->select("first_name, last_name, username, tweet, date_time");
$this->db->from('Users, Tweets');
$this->db->where('Users.id = Tweets.user_id');
$this->db->order_by('date_time', 'DESC');
$query = $this->db->get();
return $query->result_array();
}

}
?>
32 changes: 32 additions & 0 deletions www/application/views/user.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>User Tweets</title>
<style type="text/css">

</style>
</head>
<body>

<h1>Tweets Feed</h1>
<div class="container">
<div class="row">
<?php foreach($posts as $post){?>
<div class="col-md-4">
<?php echo $post['first_name'];?>
<?php echo $post['last_name'];?>
<?php echo $post['username'];?>
</div>
<div class="col-md-8">
<?php echo $post['tweet'];?>
<?php echo $post['date_time'];?>
</div>
<?php }?>
</div>
</div>

</body>
</html>

0 comments on commit 6fa68d4

Please sign in to comment.