-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shemona Singh
authored and
Shemona Singh
committed
Dec 3, 2017
1 parent
f2345dc
commit 6fa68d4
Showing
4 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |