From f2345dcf3248c7cb7988340a999f238e7dfcfda7 Mon Sep 17 00:00:00 2001 From: Shemona Singh Date: Fri, 1 Dec 2017 16:15:07 -0500 Subject: [PATCH] finished content of all tweets page --- db/lamp_2017-12-01.sql | 23 +++++++-------- www/application/controllers/All_Tweets.php | 2 +- www/application/models/All_Tweets_Model.php | 6 ++-- www/application/views/home.php | 31 +++++++++++---------- www/application/views/templates/footer.php | 2 +- 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/db/lamp_2017-12-01.sql b/db/lamp_2017-12-01.sql index ef50ce6..c1ed7f5 100644 --- a/db/lamp_2017-12-01.sql +++ b/db/lamp_2017-12-01.sql @@ -7,7 +7,7 @@ # # Host: 127.0.0.1 (MySQL 5.7.20) # Database: lamp -# Generation Time: 2017-12-01 19:30:46 +0000 +# Generation Time: 2017-12-01 20:43:00 +0000 # ************************************************************ @@ -27,19 +27,23 @@ DROP TABLE IF EXISTS `Tweets`; CREATE TABLE `Tweets` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `tweet_id` bigint(11) DEFAULT NULL, + `tweet_id` int(11) DEFAULT NULL, `tweet` char(140) DEFAULT NULL, `date_time` datetime DEFAULT NULL, + `user_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; LOCK TABLES `Tweets` WRITE; /*!40000 ALTER TABLE `Tweets` DISABLE KEYS */; -INSERT INTO `Tweets` (`id`, `tweet_id`, `tweet`, `date_time`) +INSERT INTO `Tweets` (`id`, `tweet_id`, `tweet`, `date_time`, `user_id`) VALUES - (1,123,'testing tweet! one two three','1000-01-01 00:00:00'), - (2,456,'testing tweet again! four five six','1000-01-01 00:00:00'); + (1,1,'testing tweet! one two three','1000-01-01 00:00:00',1), + (2,2,'hiiii this is my second tweet','1000-01-01 00:00:00',1), + (3,3,'first twitter tweet omg so kewl','1000-01-01 00:00:00',2), + (4,4,'3rd tweet now so pro','1000-01-01 00:00:00',1), + (5,5,'tweet tweet tweet cant stop me now','1000-01-01 00:00:00',2); /*!40000 ALTER TABLE `Tweets` ENABLE KEYS */; UNLOCK TABLES; @@ -57,21 +61,18 @@ CREATE TABLE `Users` ( `username` char(20) DEFAULT '', `password` text, `email` text, - `picture` text, - `bio` char(140) DEFAULT '', `url` text, `location` text, - `date_time` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; LOCK TABLES `Users` WRITE; /*!40000 ALTER TABLE `Users` DISABLE KEYS */; -INSERT INTO `Users` (`id`, `first_name`, `last_name`, `username`, `password`, `email`, `picture`, `bio`, `url`, `location`, `date_time`) +INSERT INTO `Users` (`id`, `first_name`, `last_name`, `username`, `password`, `email`, `url`, `location`) VALUES - (1,'shemona','singh','mona','pass','shemona.singh@uconn.edu',NULL,'',NULL,'milford','1000-01-01 00:00:00'), - (2,'chris','stumper','chris','pass2','chris.stumper@uconn.edu',NULL,'',NULL,'simsbury','1000-01-01 00:00:00'); + (1,'shemona','singh','mona','pass','shemona.singh@uconn.edu',NULL,'milford'), + (2,'christopher','stumper','chris','pass2','chris.stumper@uconn.edu',NULL,'simsbury'); /*!40000 ALTER TABLE `Users` ENABLE KEYS */; UNLOCK TABLES; diff --git a/www/application/controllers/All_Tweets.php b/www/application/controllers/All_Tweets.php index d5bcca1..fbad88c 100644 --- a/www/application/controllers/All_Tweets.php +++ b/www/application/controllers/All_Tweets.php @@ -7,7 +7,7 @@ function __Construct(){ parent::__Construct (); $this->load->database(); // load database $this->load->model('All_Tweets_Model'); // load model - $this->output->enable_profiler(TRUE); + $this->output->disable_profiler(TRUE); } public function index() { diff --git a/www/application/models/All_Tweets_Model.php b/www/application/models/All_Tweets_Model.php index cab9a72..1e0f488 100644 --- a/www/application/models/All_Tweets_Model.php +++ b/www/application/models/All_Tweets_Model.php @@ -2,8 +2,10 @@ class All_Tweets_Model extends CI_Model { function getPosts(){ - $this->db->select("first_name,last_name,username"); - $this->db->from('Users'); + $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(); } diff --git a/www/application/views/home.php b/www/application/views/home.php index 1ab9162..7540c13 100644 --- a/www/application/views/home.php +++ b/www/application/views/home.php @@ -11,21 +11,22 @@ -

Output Data

- - - - - - - - - - - -
Post IdPost Title
- - +

Tweets Feed

+
+
+ +
+ + + +
+
+ + +
+ +
+
diff --git a/www/application/views/templates/footer.php b/www/application/views/templates/footer.php index e3f4905..4d37132 100644 --- a/www/application/views/templates/footer.php +++ b/www/application/views/templates/footer.php @@ -1,5 +1,5 @@ © 2017 - +